Hobrasoft httpd server
Embedded HTTP server for Qt and C++
abstractcontroller.h
Go to the documentation of this file.
1 
7 #ifndef _Httpd_AbstractController_H_
8 #define _Httpd_AbstractController_H_
9 
10 #include <QObject>
11 #include <QString>
12 #include <QVariant>
13 #include <QVariantMap>
14 #include "httprequesthandler.h"
15 
16 namespace HobrasoftHttpd {
17 class HttpRequestHandler;
18 class HttpRequest;
19 class HttpResponse;
20 class HttpConnection;
21 }
22 
23 namespace Example {
24 namespace Httpd {
25 
115  Q_OBJECT
116  public:
117 
122 
127 
131  void setCheckId(bool x) { m_checkId = x; }
132 
138  bool checkId() const { return m_checkId; }
139 
140  protected:
141 
152  virtual bool exists(const QString& id) const { Q_UNUSED(id); return true; }
153 
154 
160  virtual void serviceOK (HobrasoftHttpd::HttpRequest *request, HobrasoftHttpd::HttpResponse *response, const QVariant& data = QVariant() );
161 
179  virtual void serviceError (HobrasoftHttpd::HttpRequest *request, HobrasoftHttpd::HttpResponse *response, int code, const QString& error, const QString& reason);
180 
186  virtual void serviceList (HobrasoftHttpd::HttpRequest *request, HobrasoftHttpd::HttpResponse *response);
187 
193  virtual void serviceEvents (HobrasoftHttpd::HttpRequest *request, HobrasoftHttpd::HttpResponse *response);
194 
200  virtual void serviceIdEvents (HobrasoftHttpd::HttpRequest *request, HobrasoftHttpd::HttpResponse *response, const QString& id);
201 
207  virtual void serviceIdGet (HobrasoftHttpd::HttpRequest *request, HobrasoftHttpd::HttpResponse *response, const QString& id);
208 
216  virtual void serviceIdDelete (HobrasoftHttpd::HttpRequest *request, HobrasoftHttpd::HttpResponse *response, const QString& id);
217 
225  virtual void serviceIdPut (HobrasoftHttpd::HttpRequest *request, HobrasoftHttpd::HttpResponse *response, const QVariantMap& data);
226 
234  virtual void serviceIdPost (HobrasoftHttpd::HttpRequest *request, HobrasoftHttpd::HttpResponse *response, const QVariantMap& data);
235 
242  virtual void serviceEvent (HobrasoftHttpd::HttpRequest *request, HobrasoftHttpd::HttpResponse *response, const QVariant& data);
243 
244  HobrasoftHttpd::HttpRequest *request() const;
246 
247  private:
248  #ifndef DOXYGEN_SHOULD_SKIP_THIS
249  HobrasoftHttpd::HttpRequest *m_request;
250  HobrasoftHttpd::HttpConnection *m_connection;
251  bool m_checkId;
252  #endif
253 
254 };
255 
256 }
257 }
258 
259 #endif
virtual void serviceOK(HobrasoftHttpd::HttpRequest *request, HobrasoftHttpd::HttpResponse *response, const QVariant &data=QVariant())
Sends 200 OK response.
AbstractController(HobrasoftHttpd::HttpConnection *parent)
Constructor.
HttpResponse * response()
Returns new instance of HttpResponse class.
Namespace for Example.
Definition: application.h:11
bool checkId() const
Returns the state of checkId.
HttpConnection * connection() const
Returns pointer to parent HttpConnection class.
Abstract class for processing unified HTTP requests to server&#39;s API.
virtual void service(HobrasoftHttpd::HttpRequest *request, HobrasoftHttpd::HttpResponse *response)
Request processing.
virtual bool exists(const QString &id) const
Check existence of th ID.
Response to HTTP request - headers, cookies and body.
Definition: httpresponse.h:30
Processes incoming requests.
Processes HTTP request, parses headers, body and files sent by HTTP protocol.
Definition: httprequest.h:23
void setCheckId(bool x)
If the checkId is set then the exixtence of the item is checked in requests PUT and POST...
Own implementation of HTTP server.
Definition: httpd.h:31
Namespace of HTTP server.
One single connection to http server.