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

class wrapper for middleware More...

#include <middleware.h>

Inheritance diagram for Middleware:
Inheritance graph
Collaboration diagram for Middleware:
Collaboration graph

Public Member Functions

 Middleware (const char *nameID)
 
virtual ~Middleware ()
 
void setContent (Request *request, Response *response)
 
void addValueToMap (const char *key, const char *value)
 
bool getValueFromMap (const char *key, std::string &value)
 
std::unordered_map< std::string, std::string > * getMap ()
 
virtual bool autoExec ()=0
 
virtual void exec ()=0
 
std::string getNameID ()
 
virtual void clear ()
 

Protected Attributes

Requestrequest
 
Responseresponse
 
std::unordered_map< std::string, std::string > * map
 

Detailed Description

class wrapper for middleware

Middleware have got current request and response objects and also map for key-value pairs. Method exec and autoExec can use request and response objects to perform actions.

Constructor & Destructor Documentation

Middleware::Middleware ( const char *  nameID)

Create empty middleware, where Request and Response objects are null

Parameters
nameIDname id as string
virtual Middleware::~Middleware ( )
virtual

Member Function Documentation

void Middleware::addValueToMap ( const char *  key,
const char *  value 
)

Add value to map by key. If key exists, it should be overwritten

Parameters
keykey as string
valuevalue as string
virtual bool Middleware::autoExec ( )
pure virtual

Check if current request allow do exec method

Returns
true, if need do exec with current request, false otherwise

Implemented in AuthMiddleware, FsMiddleware, JsonMiddleware, FormMiddleware, HtmlMiddleware, and CookieMiddleware.

virtual void Middleware::clear ( )
virtual

delete all data, saved in internal values, set to default

Reimplemented in AuthMiddleware, HtmlMiddleware, CookieMiddleware, JsonMiddleware, and FormMiddleware.

virtual void Middleware::exec ( )
pure virtual

perform operation with request and response objects

Implemented in AuthMiddleware, FsMiddleware, JsonMiddleware, FormMiddleware, HtmlMiddleware, and CookieMiddleware.

std::unordered_map<std::string, std::string>* Middleware::getMap ( )

get map of key-value pairs

Returns
map of key-value pairs
std::string Middleware::getNameID ( )

get name id of middleware

Returns
name id
bool Middleware::getValueFromMap ( const char *  key,
std::string &  value 
)

get value from map by key

Parameters
keyneeded key
valueout param, if value exists should be written, do nothing otherwise
Returns
true if key exists in map, false otherwise
void Middleware::setContent ( Request request,
Response response 
)

set request and response objects into Middleware

Parameters
requestrequest object
responseresponse object

Member Data Documentation

std::unordered_map<std::string, std::string>* Middleware::map
protected
Request* Middleware::request
protected
Response* Middleware::response
protected

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