Web framework C++
2.0.0
Simple web framework on c++ designed to easily create web pages, etc
|
This class is wrapper for important data (like Response, DB, Middleware etc.), which is needed to handlers. More...
#include <context.h>
Public Member Functions | |
Context () | |
~Context () | |
Request * | getRequest () |
Response * | getResponse () |
void | setRequest (Request *request) |
void | setResponse (Response *response) |
void | setMiddlewareList (std::vector< Middleware * > *middlewareList) |
void | setPermanentlyRedirect (const char *uri) |
void | setTemporaryRedirect (const char *uri) |
void | setRedirect (const char *uri, int code) |
Middleware * | getMiddlewareByNameID (const char *nameID) |
void | emitCloseEvent () |
bool | isClosed () |
This class is wrapper for important data (like Response, DB, Middleware etc.), which is needed to handlers.
This class collects a data about current request, which was parsed from str, have a pointer to Response object, which will be serialized to client in future (here could be some written data from previous responses), also there are references to all added middleware (you could get some by id) and database, which is ready to perform method exec
Context::Context | ( | ) |
void Context::emitCloseEvent | ( | ) |
Emit signal to stop executing operation. Handler, which used this will be last executed handler in app
Middleware* Context::getMiddlewareByNameID | ( | const char * | nameID | ) |
Method returns added Middleware by id (in string)
nameID | id of middleware, which was set at startup |
Response* Context::getResponse | ( | ) |
Gives current response. Could be modified by previous handlers
bool Context::isClosed | ( | ) |
Checks, if handlers emitted CloseEvent
void Context::setMiddlewareList | ( | std::vector< Middleware * > * | middlewareList | ) |
sets vector of Middleware objects, which can be accessed by handlers
middlewareList | std::vector of Middleware objects |
void Context::setPermanentlyRedirect | ( | const char * | uri | ) |
Set permanent (code 301) redirect headers to Response
uri | destination uri, where current request will be redirected |
void Context::setRedirect | ( | const char * | uri, |
int | code | ||
) |
Set redirect headers to Response
uri | destination uri, where current request will be redirected |
code | http code of redirect |
void Context::setRequest | ( | Request * | request | ) |
void Context::setResponse | ( | Response * | response | ) |
void Context::setTemporaryRedirect | ( | const char * | uri | ) |
Set temporary (code 302) redirect headers to Response
uri | destination uri, where current request will be redirected |