From 5fdee7e15e3d290c44cd74ecfea0efb618585a08 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Sat, 22 Sep 2018 03:07:20 +0200 Subject: [PATCH] Implemented basic example response --- helloworldapplication.cpp | 12 ++++++++++++ helloworldapplication.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/helloworldapplication.cpp b/helloworldapplication.cpp index a40842e..37642bd 100644 --- a/helloworldapplication.cpp +++ b/helloworldapplication.cpp @@ -1,5 +1,9 @@ #include "helloworldapplication.h" +#include "httprequest.h" +#include "httpresponse.h" +#include "httpclientconnection.h" + HelloWorldApplication::HelloWorldApplication(const QJsonObject &config, QObject *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); +} diff --git a/helloworldapplication.h b/helloworldapplication.h index 3688e19..cf553a8 100644 --- a/helloworldapplication.h +++ b/helloworldapplication.h @@ -12,4 +12,6 @@ public: HelloWorldApplication(const QJsonObject &config, QObject *parent = Q_NULLPTR); void start() Q_DECL_OVERRIDE; + + void handleRequest(HttpClientConnection *connection, const HttpRequest &request) Q_DECL_OVERRIDE; };