mirror of
https://gitee.com/spark-store-project/spark-web-app-runtime.git
synced 2025-12-15 03:22:05 +08:00
新增内置WEB Server功能.
This commit is contained in:
45
SparkWebAppRuntime/httpd.h
Normal file
45
SparkWebAppRuntime/httpd.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef HTTPSD_H
|
||||
#define HTTPSD_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
#define SSL_SERVER 1
|
||||
#else
|
||||
#define SSL_SERVER 0
|
||||
#endif
|
||||
|
||||
namespace httplib
|
||||
{
|
||||
class Server;
|
||||
#if SSL_SERVER
|
||||
class SSLServer;
|
||||
#endif
|
||||
}
|
||||
|
||||
class HttpD : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
#if SSL_SERVER
|
||||
explicit HttpD(QString szRootPath, quint16 u16Port, quint16 u16sslPort, QObject *parent = nullptr);
|
||||
#else
|
||||
explicit HttpD(QString szRootPath, quint16 u16Port, QObject *parent = nullptr);
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
private:
|
||||
QString m_szRootPath;
|
||||
#if SSL_SERVER
|
||||
httplib::SSLServer *m_httpsServer;
|
||||
quint16 m_u16HttpsServerBindPort;
|
||||
#endif
|
||||
httplib::Server *m_httpServer;
|
||||
quint16 m_u16HttpServerBindPort;
|
||||
|
||||
};
|
||||
|
||||
#endif // HTTPSD_H
|
||||
Reference in New Issue
Block a user