Web framework C++  2.0.0
Simple web framework on c++ designed to easily create web pages, etc
All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
handler.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include "context.h"
5 
13 class Handler {
14  bool hasRoute;
15  Context * context;
16  std::string route;
17  HTTP::Method method;
18  Handler * next;
19 protected:
26  Context * getContext();
27 public:
36  explicit Handler(const char * route = nullptr, HTTP::Method method = HTTP::Method::ANY, Handler * next = nullptr);
37 
41  virtual ~Handler();
42 
49  virtual void setNext(Handler * next);
50 
57  virtual void add(Handler * handler);
58 
65  bool isRouted();
66 
73  std::string getRoute();
74 
82 
89  void setContext(Context * context);
90 
95  void handleRequest();
96 
100  virtual void exec() = 0;
101 private:
109  bool shouldHandleRequest();
110 };
std::string getRoute()
virtual void setNext(Handler *next)
This class is wrapper for important data (like Response, DB, Middleware etc.), which is needed to han...
Definition: context.h:17
void setContext(Context *context)
void handleRequest()
HTTP::Method getMethod()
virtual ~Handler()
object of this class executes every time on new request, this object (and others) construct response ...
Definition: handler.h:13
Context * getContext()
virtual void add(Handler *handler)
virtual void exec()=0
bool isRouted()
Handler(const char *route=nullptr, HTTP::Method method=HTTP::Method::ANY, Handler *next=nullptr)
Method
Definition: http.h:16