RESTinio
Public Member Functions | Private Types | Private Attributes | List of all members
restinio::router::express_router_t< Regex_Engine > Class Template Reference

Express.js style router. More...

#include <express.hpp>

Public Member Functions

 express_router_t ()=default
 
 express_router_t (express_router_t &&)=default
 
request_handling_status_t operator() (request_handle_t req) const
 
void non_matched_request_handler (non_matched_request_handler_t nmrh)
 Set handler for requests that don't match any route. More...
 
void add_handler (http_method_id_t method, string_view_t route_path, express_request_handler_t handler)
 Add handlers. More...
 
void add_handler (http_method_id_t method, string_view_t route_path, const path2regex::options_t &options, express_request_handler_t handler)
 
void http_delete (string_view_t route_path, express_request_handler_t handler)
 
void http_delete (string_view_t route_path, const path2regex::options_t &options, express_request_handler_t handler)
 
void http_get (string_view_t route_path, express_request_handler_t handler)
 
void http_get (string_view_t route_path, const path2regex::options_t &options, express_request_handler_t handler)
 
void http_head (string_view_t route_path, express_request_handler_t handler)
 
void http_head (string_view_t route_path, const path2regex::options_t &options, express_request_handler_t handler)
 
void http_post (string_view_t route_path, express_request_handler_t handler)
 
void http_post (string_view_t route_path, const path2regex::options_t &options, express_request_handler_t handler)
 
void http_put (string_view_t route_path, express_request_handler_t handler)
 
void http_put (string_view_t route_path, const path2regex::options_t &options, express_request_handler_t handler)
 

Private Types

using route_entry_t = express_route_entry_t< Regex_Engine >
 

Private Attributes

std::vector< route_entry_tm_handlers
 A list of existing routes. More...
 
non_matched_request_handler_t m_non_matched_request_handler
 Handler that is called for requests that don't match any route. More...
 

Detailed Description

template<typename Regex_Engine = std_regex_engine_t>
class restinio::router::express_router_t< Regex_Engine >

Express.js style router.

Examples:
sample/hello_world/main.cpp, and sample/websocket_wss/main.cpp.

Definition at line 516 of file express.hpp.

Member Typedef Documentation

◆ route_entry_t

template<typename Regex_Engine = std_regex_engine_t>
using restinio::router::express_router_t< Regex_Engine >::route_entry_t = express_route_entry_t< Regex_Engine >
private

Definition at line 700 of file express.hpp.

Constructor & Destructor Documentation

◆ express_router_t() [1/2]

template<typename Regex_Engine = std_regex_engine_t>
restinio::router::express_router_t< Regex_Engine >::express_router_t ( )
default

◆ express_router_t() [2/2]

template<typename Regex_Engine = std_regex_engine_t>
restinio::router::express_router_t< Regex_Engine >::express_router_t ( express_router_t< Regex_Engine > &&  )
default

Member Function Documentation

◆ add_handler() [1/2]

template<typename Regex_Engine = std_regex_engine_t>
void restinio::router::express_router_t< Regex_Engine >::add_handler ( http_method_id_t  method,
string_view_t  route_path,
express_request_handler_t  handler 
)
inline

Add handlers.

Definition at line 549 of file express.hpp.

◆ add_handler() [2/2]

template<typename Regex_Engine = std_regex_engine_t>
void restinio::router::express_router_t< Regex_Engine >::add_handler ( http_method_id_t  method,
string_view_t  route_path,
const path2regex::options_t options,
express_request_handler_t  handler 
)
inline

Definition at line 562 of file express.hpp.

◆ http_delete() [1/2]

template<typename Regex_Engine = std_regex_engine_t>
void restinio::router::express_router_t< Regex_Engine >::http_delete ( string_view_t  route_path,
express_request_handler_t  handler 
)
inline

Definition at line 572 of file express.hpp.

◆ http_delete() [2/2]

template<typename Regex_Engine = std_regex_engine_t>
void restinio::router::express_router_t< Regex_Engine >::http_delete ( string_view_t  route_path,
const path2regex::options_t options,
express_request_handler_t  handler 
)
inline

Definition at line 583 of file express.hpp.

◆ http_get() [1/2]

template<typename Regex_Engine = std_regex_engine_t>
void restinio::router::express_router_t< Regex_Engine >::http_get ( string_view_t  route_path,
express_request_handler_t  handler 
)
inline
Examples:
sample/hello_world/main.cpp.

Definition at line 596 of file express.hpp.

◆ http_get() [2/2]

template<typename Regex_Engine = std_regex_engine_t>
void restinio::router::express_router_t< Regex_Engine >::http_get ( string_view_t  route_path,
const path2regex::options_t options,
express_request_handler_t  handler 
)
inline

Definition at line 607 of file express.hpp.

◆ http_head() [1/2]

template<typename Regex_Engine = std_regex_engine_t>
void restinio::router::express_router_t< Regex_Engine >::http_head ( string_view_t  route_path,
express_request_handler_t  handler 
)
inline

Definition at line 620 of file express.hpp.

◆ http_head() [2/2]

template<typename Regex_Engine = std_regex_engine_t>
void restinio::router::express_router_t< Regex_Engine >::http_head ( string_view_t  route_path,
const path2regex::options_t options,
express_request_handler_t  handler 
)
inline

Definition at line 631 of file express.hpp.

◆ http_post() [1/2]

template<typename Regex_Engine = std_regex_engine_t>
void restinio::router::express_router_t< Regex_Engine >::http_post ( string_view_t  route_path,
express_request_handler_t  handler 
)
inline

Definition at line 644 of file express.hpp.

◆ http_post() [2/2]

template<typename Regex_Engine = std_regex_engine_t>
void restinio::router::express_router_t< Regex_Engine >::http_post ( string_view_t  route_path,
const path2regex::options_t options,
express_request_handler_t  handler 
)
inline

Definition at line 655 of file express.hpp.

◆ http_put() [1/2]

template<typename Regex_Engine = std_regex_engine_t>
void restinio::router::express_router_t< Regex_Engine >::http_put ( string_view_t  route_path,
express_request_handler_t  handler 
)
inline

Definition at line 668 of file express.hpp.

◆ http_put() [2/2]

template<typename Regex_Engine = std_regex_engine_t>
void restinio::router::express_router_t< Regex_Engine >::http_put ( string_view_t  route_path,
const path2regex::options_t options,
express_request_handler_t  handler 
)
inline

Definition at line 679 of file express.hpp.

◆ non_matched_request_handler()

template<typename Regex_Engine = std_regex_engine_t>
void restinio::router::express_router_t< Regex_Engine >::non_matched_request_handler ( non_matched_request_handler_t  nmrh)
inline

Set handler for requests that don't match any route.

Definition at line 694 of file express.hpp.

◆ operator()()

template<typename Regex_Engine = std_regex_engine_t>
request_handling_status_t restinio::router::express_router_t< Regex_Engine >::operator() ( request_handle_t  req) const
inline

Definition at line 523 of file express.hpp.

Member Data Documentation

◆ m_handlers

template<typename Regex_Engine = std_regex_engine_t>
std::vector< route_entry_t > restinio::router::express_router_t< Regex_Engine >::m_handlers
private

A list of existing routes.

Definition at line 703 of file express.hpp.

◆ m_non_matched_request_handler

template<typename Regex_Engine = std_regex_engine_t>
non_matched_request_handler_t restinio::router::express_router_t< Regex_Engine >::m_non_matched_request_handler
private

Handler that is called for requests that don't match any route.

Definition at line 706 of file express.hpp.


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