Implemented basic example response

This commit is contained in:
0xFEEDC0DE64
2018-09-22 03:07:20 +02:00
parent 6d7c8d789f
commit 5fdee7e15e
2 changed files with 14 additions and 0 deletions

View File

@@ -1,5 +1,9 @@
#include "helloworldapplication.h" #include "helloworldapplication.h"
#include "httprequest.h"
#include "httpresponse.h"
#include "httpclientconnection.h"
HelloWorldApplication::HelloWorldApplication(const QJsonObject &config, QObject *parent) : HelloWorldApplication::HelloWorldApplication(const QJsonObject &config, QObject *parent) :
WebApplication(parent) WebApplication(parent)
{ {
@@ -10,3 +14,11 @@ void HelloWorldApplication::start()
{ {
} }
void HelloWorldApplication::handleRequest(HttpClientConnection *connection, const HttpRequest &request)
{
HttpResponse response;
response.protocol = request.protocol;
response.statusCode = HttpResponse::StatusCode::OK;
connection->sendResponse(response, "Hello from HelloWorldApplication: " + request.path);
}

View File

@@ -12,4 +12,6 @@ public:
HelloWorldApplication(const QJsonObject &config, QObject *parent = Q_NULLPTR); HelloWorldApplication(const QJsonObject &config, QObject *parent = Q_NULLPTR);
void start() Q_DECL_OVERRIDE; void start() Q_DECL_OVERRIDE;
void handleRequest(HttpClientConnection *connection, const HttpRequest &request) Q_DECL_OVERRIDE;
}; };