2025-03-09 10:26:52 +05:00
|
|
|
#ifndef RESTAPISERVER_H
|
|
|
|
|
#define RESTAPISERVER_H
|
|
|
|
|
|
|
|
|
|
#include <odb/database.hxx>
|
|
|
|
|
|
2025-03-16 10:46:06 +05:00
|
|
|
#include <QObject>
|
2025-03-09 10:26:52 +05:00
|
|
|
#include <QTcpServer>
|
|
|
|
|
#include <QTcpSocket>
|
|
|
|
|
|
2025-03-16 10:46:06 +05:00
|
|
|
class Q_DECL_EXPORT RestApiServer : public QTcpServer
|
2025-03-09 10:26:52 +05:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
explicit RestApiServer(odb::core::database& db, QObject* parent = nullptr);
|
|
|
|
|
void start(quint16 port = 8080);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void incomingConnection(qintptr socketDescriptor) override;
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void handleRequest();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QByteArray processRequest(const QString& request);
|
|
|
|
|
|
|
|
|
|
odb::core::database& m_db;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // RESTAPISERVER_H
|