C++ Web Framework  3.0
controller.h
1 /*
2  Copyright 2017 Herik Lima de Castro and Marcelo Medeiros Eler
3  Distributed under MIT license, or public domain if desired and
4  recognized in your jurisdiction.
5  See file LICENSE for detail.
6 */
7 
8 #ifndef CONTROLLER_H
9 #define CONTROLLER_H
10 
11 #include <QString>
12 #include "variant.h"
13 #include "constants.h"
14 #include "request.h"
15 #include "cppwebframework_global.h"
16 
17 CWF_BEGIN_NAMESPACE
18 class Request;
19 class Response;
20 
28 class CPPWEBFRAMEWORKSHARED_EXPORT Controller
29 {
36  void doMessage(Request &req, Response &resp, QString method) const;
37 public:
41  virtual ~Controller() {}
47  virtual void doDelete(Request &req, Response &resp) const { doMessage(req, resp, HTTP::METHOD::DELETE); }
53  virtual void doGet(Request &req, Response &resp) const { doMessage(req, resp, HTTP::METHOD::GET); }
59  virtual void doOptions(Request &req, Response &resp) const { doMessage(req, resp, HTTP::METHOD::OPTIONS); }
65  virtual void doPost(Request &req, Response &resp) const { doMessage(req, resp, HTTP::METHOD::POST); }
71  virtual void doPut(Request &req, Response &resp) const { doMessage(req, resp, HTTP::METHOD::PUT); }
77  virtual void doTrace(Request &req, Response &resp) const { doMessage(req, resp, HTTP::METHOD::TRACE); }
78 };
79 
80 CWF_END_NAMESPACE
81 
82 #endif // CONTROLLER_H
virtual ~Controller()
Destructor.
Definition: controller.h:41
virtual void doGet(Request &req, Response &resp) const
This is an virtual method that can be overloaded to attend the get request method.
Definition: controller.h:53
virtual void doDelete(Request &req, Response &resp) const
This is an virtual method that can be overloaded to attend the delete request method.
Definition: controller.h:47
The Request class holds all information about a http request.
Definition: request.h:27
virtual void doOptions(Request &req, Response &resp) const
This is an virtual method that can be overloaded to attend the options request method.
Definition: controller.h:59
The Controller class is responsable to attend a request from a specific url. You will need to create ...
Definition: controller.h:28
virtual void doPut(Request &req, Response &resp) const
This is an virtual method that can be overloaded to attend the put request method.
Definition: controller.h:71
virtual void doTrace(Request &req, Response &resp) const
This is an virtual method that can be overloaded to attend the trace request method.
Definition: controller.h:77
The Response class is responsable to response a Http request.
Definition: response.h:25
virtual void doPost(Request &req, Response &resp) const
This is an virtual method that can be overloaded to attend the post request method.
Definition: controller.h:65