Web framework C++  2.0.0
Simple web framework on c++ designed to easily create web pages, etc
Public Member Functions | Protected Member Functions | List of all members
Handler Class Referenceabstract

object of this class executes every time on new request, this object (and others) construct response to client More...

#include <handler.h>

Inheritance diagram for Handler:
Inheritance graph
Collaboration diagram for Handler:
Collaboration graph

Public Member Functions

 Handler (const char *route=nullptr, HTTP::Method method=HTTP::Method::ANY, Handler *next=nullptr)
 
virtual ~Handler ()
 
virtual void setNext (Handler *next)
 
virtual void add (Handler *handler)
 
bool isRouted ()
 
std::string getRoute ()
 
HTTP::Method getMethod ()
 
void setContext (Context *context)
 
void handleRequest ()
 
virtual void exec ()=0
 

Protected Member Functions

ContextgetContext ()
 

Detailed Description

object of this class executes every time on new request, this object (and others) construct response to client

Handler object can be common (will execute on every response) or adjusted to some specified uri path. It can get all info about request, use added middleware, and make response

Constructor & Destructor Documentation

Handler::Handler ( const char *  route = nullptr,
HTTP::Method  method = HTTP::Method::ANY,
Handler next = nullptr 
)
explicit

create handler with params: common or routed one

Parameters
routeuri path route, if null - handler will be common
methoduri method, if ANY will be executed on any methods
virtual Handler::~Handler ( )
virtual

destructs local variables

Member Function Documentation

virtual void Handler::add ( Handler handler)
virtual

add handler to end of current chain

Parameters
handlerHandler object

Reimplemented in AuthorizedHandler.

virtual void Handler::exec ( )
pure virtual

this method will be executed on every request (or uri path if set)

Implemented in AuthorizedHandler, and FileHandler.

Context* Handler::getContext ( )
protected

get current context

Returns
current Context object
HTTP::Method Handler::getMethod ( )

get Context object

Returns
current Context object
std::string Handler::getRoute ( )

get route of handler

Returns
uri http route path
void Handler::handleRequest ( )

if method shouldHandleRequest returns true, method exec is executed and if there is a next handler, call method handleRequest

bool Handler::isRouted ( )

check, if route is set

Returns
true, if handler for specified route, false if it's common one
void Handler::setContext ( Context context)

set Context object

Parameters
contextContext object
virtual void Handler::setNext ( Handler next)
virtual

set next handler to execute

Parameters
nextHandler object

Reimplemented in AuthorizedHandler.


The documentation for this class was generated from the following file: