httprequesthandler.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. @file
  3. @author Stefan Frings
  4. */
  5. #ifndef HTTPREQUESTHANDLER_H
  6. #define HTTPREQUESTHANDLER_H
  7. #include "httpglobal.h"
  8. #include "httprequest.h"
  9. #include "httpresponse.h"
  10. namespace stefanfrings {
  11. /**
  12. The request handler generates a response for each HTTP request. Web Applications
  13. usually have one central request handler that maps incoming requests to several
  14. controllers (servlets) based on the requested path.
  15. <p>
  16. You need to override the service() method or you will always get an HTTP error 501.
  17. <p>
  18. @warning Be aware that the main request handler instance must be created on the heap and
  19. that it is used by multiple threads simultaneously.
  20. @see StaticFileController which delivers static local files.
  21. */
  22. class DECLSPEC HttpRequestHandler : public QObject {
  23. Q_OBJECT
  24. Q_DISABLE_COPY(HttpRequestHandler)
  25. public:
  26. /**
  27. * Constructor.
  28. * @param parent Parent object.
  29. */
  30. HttpRequestHandler(QObject* parent=nullptr);
  31. /** Destructor */
  32. virtual ~HttpRequestHandler();
  33. /**
  34. Generate a response for an incoming HTTP request.
  35. @param request The received HTTP request
  36. @param response Must be used to return the response
  37. @warning This method must be thread safe
  38. */
  39. virtual void service(HttpRequest& request, HttpResponse& response);
  40. };
  41. } // end of namespace
  42. #endif // HTTPREQUESTHANDLER_H