2025-08-08 06:44:18 +04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QScopedPointer>
|
|
|
|
|
#include <QHttpServer>
|
|
|
|
|
#include <QHttpServerRequest>
|
|
|
|
|
#include <QHttpServerResponse>
|
|
|
|
|
#include <QTcpServer>
|
|
|
|
|
#include <QWeakPointer>
|
|
|
|
|
#include "iproxyservice.h"
|
|
|
|
|
|
|
|
|
|
class HttpApi : public QObject {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit HttpApi(QWeakPointer<IProxyService> service, QObject* parent = nullptr);
|
|
|
|
|
~HttpApi();
|
|
|
|
|
|
|
|
|
|
bool start(quint16 port);
|
|
|
|
|
void stop();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void setupRoutes();
|
|
|
|
|
|
2025-12-31 19:30:29 +04:00
|
|
|
QHttpServerResponse handlePostUp();
|
|
|
|
|
QHttpServerResponse handlePostDown();
|
|
|
|
|
QHttpServerResponse handleGetPing() const;
|
2025-08-08 06:44:18 +04:00
|
|
|
|
|
|
|
|
QHttpServer m_server;
|
|
|
|
|
QScopedPointer<QTcpServer> m_tcpServer;
|
|
|
|
|
QWeakPointer<IProxyService> m_service;
|
|
|
|
|
};
|