#include <route_matcher.hpp>
hande the route matching logic build regex for a given route of the server and match requested path by http clients
◆ route_matcher()
netflex::routing::route_matcher::route_matcher |
( |
const std::string & |
path | ) |
|
|
explicit |
ctor
- Parameters
-
path | path associated to the route. It will be used to build an regex representation of the route to be used for matching |
◆ build_match_regex()
void netflex::routing::route_matcher::build_match_regex |
( |
const std::string & |
path | ) |
|
|
protected |
build matching regex that is, given a path, construct a regex that can be used by match() and store it in m_match_regex
- Parameters
-
path | path to be used for regex construction |
◆ match()
bool netflex::routing::route_matcher::match |
( |
const std::string & |
path, |
|
|
params_t & |
params |
|
) |
| const |
match the given path with the underlying route
- Parameters
-
path | path to match |
params | place where to store params of the requested path (for example /articles/1?author=simon) will store {article:1, author: simon} for underlying route /articles/:id. store nothing if mismatch |
- Returns
- whether the path matched or not
◆ match_get_params()
void netflex::routing::route_matcher::match_get_params |
( |
const std::string & |
path, |
|
|
params_t & |
params |
|
) |
| const |
|
protected |
match GET request params given a requested path
- Parameters
-
path | path to match |
params | place where to store params of the requested path (for example /articles/1?author=simon) will store {author: simon}. |
◆ m_match_regex
std::regex netflex::routing::route_matcher::m_match_regex |
|
protected |
matching regex (regex object)
◆ m_match_regex_str
std::string netflex::routing::route_matcher::m_match_regex_str |
|
protected |
matching regex (string object)
◆ m_url_params
std::vector<std::string> netflex::routing::route_matcher::m_url_params |
|
protected |
url params to match, in order of appearance for example, for route /articles/:id/author/:name, this would be {id, name}
The documentation for this class was generated from the following file: