forked from dedis/Dissent
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWebService.hpp
37 lines (31 loc) · 971 Bytes
/
WebService.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef DISSENT_WEB_WEB_SERVICE_GUARD
#define DISSENT_WEB_WEB_SERVICE_GUARD
#include <QObject>
#include <QSharedPointer>
#include "qhttprequest.h"
#include "qhttpresponse.h"
#include "json.h"
namespace Dissent {
namespace Web {
/**
* WebService is the abstract base class representing the logic for
* processing a WebRequest.
*/
class WebService {
public:
virtual ~WebService();
/**
* Called to handle the incoming request
* @param request the incoming request
* @param response used to respond to the rqeuest
*/
virtual void HandleRequest(QHttpRequest *request, QHttpResponse *response) = 0;
protected:
QByteArray BuildJsonResponse(const QVariant &response, bool &success);
void SendJsonResponse(QHttpResponse *response, const QVariant &data);
void SendResponse(QHttpResponse *response, const QByteArray &data);
void SendNotFound(QHttpResponse *response);
};
}
}
#endif