29 lines
548 B
C
29 lines
548 B
C
|
|
#ifndef RESTAPISERVER_H
|
||
|
|
#define RESTAPISERVER_H
|
||
|
|
|
||
|
|
#include <odb/database.hxx>
|
||
|
|
|
||
|
|
#include <QTcpServer>
|
||
|
|
#include <QTcpSocket>
|
||
|
|
|
||
|
|
class RestApiServer : public QTcpServer
|
||
|
|
{
|
||
|
|
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
|