Mantis App v0.1.13
Loading...
Searching...
No Matches
mantis::Router Class Reference

Router class allows for managing routes as well as acting as a top-wrapper on the HttpUnit. More...

#include <router.h>

Public Member Functions

 Router ()
 
 ~Router ()=default
 
bool initialize ()
 Initialize the router instance creating tables and admin routes.
 
bool listen () const
 
void close ()
 
json addRoute (const std::string &table)
 Restart the HTTP server.
 
json updateRoute (const json &table_data=json::object())
 
json updateRouteCache (const json &table_data=json::object())
 
json removeRoute (const json &table_data=json::object())
 

Public Attributes

const std::string __class_name__ = "mantis::Router"
 

Detailed Description

Router class allows for managing routes as well as acting as a top-wrapper on the HttpUnit.

Constructor & Destructor Documentation

◆ Router()

mantis::Router::Router ( )
explicit

◆ ~Router()

mantis::Router::~Router ( )
default

Member Function Documentation

◆ addRoute()

json mantis::Router::addRoute ( const std::string &  table)

Restart the HTTP server.

Adds a new table route passed on a given table name. Used mostly when a table is added after the server is already running. The table has to be existing for routes to be created for.

Parameters
tableTable name
Returns
JSON object having success and error values.

◆ close()

void mantis::Router::close ( )

Close the HTTP Server connection Calls

See also
HttpUnit::close()

◆ initialize()

bool mantis::Router::initialize ( )

Initialize the router instance creating tables and admin routes.

◆ listen()

bool mantis::Router::listen ( ) const

Bind to a port and start listening for new connections. Calls

See also
HttpUnit::listen() under the hood.

◆ removeRoute()

json mantis::Router::removeRoute ( const json table_data = json::object())

Remove existing route(s), maybe due to deletion of a table.

Parameters
table_datamust have the deleted table's name and type.
Returns
JSON object having success and error values.

◆ updateRoute()

json mantis::Router::updateRoute ( const json table_data = json::object())

Update existing route, probably due to a change in table name and/or table type

Parameters
table_dataContains the changes, that is, old_type, old_name and new_name matching the old table name and type together with the new table name. The new table type will be fetched from the db.
Returns
JSON object having success and error values.

◆ updateRouteCache()

mantis::json mantis::Router::updateRouteCache ( const json table_data = json::object())

Update existing route internal data, probably due to a change in table internal metadata

Parameters
table_dataContains the new table schema
Returns
JSON object having success and error values.

Member Data Documentation

◆ __class_name__

const std::string mantis::Router::__class_name__ = "mantis::Router"

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