|
RAVENNAKIT
|
A simple path matcher that matches paths against patterns. More...
#include <path_matcher.hpp>
Classes | |
| class | Parameters |
| Contains parameters extracted from a path with convenience functions to convert to integers. More... | |
Public Types | |
| enum class | Error { invalid_recursive_wildcard , invalid_argument } |
Static Public Member Functions | |
| static boost::system::result< bool, Error > | match (const std::string_view path, const std::string_view pattern, Parameters *parameters=nullptr) |
| Match a path against a pattern. | |
Static Public Attributes | |
| static constexpr auto | k_loop_upper_bound = 100'000 |
A simple path matcher that matches paths against patterns.
For example, it can be used to match URLs against patterns like "/user/{id}" or "/user/ **".
Path parameters are enclosed in curly braces, e.g. "/user/{id}" and fed into an instance of Parameters. The single wildcard "*" matches any single path segment. It must appear without additional characters. The double wildcard "**" matches any path below the current level. It can only appear at the end of the pattern.
Look at the unit tests for examples of usage.
Definition at line 45 of file path_matcher.hpp.
|
strong |
| Enumerator | |
|---|---|
| invalid_recursive_wildcard | |
| invalid_argument | |
Definition at line 49 of file path_matcher.hpp.
|
inlinestaticnodiscard |
Match a path against a pattern.
Note: if the pattern contains a parameter, the parameter argument must not be null, otherwise the function will return false.
| path | The path to match (e.g. "/user/123"). |
| pattern | The pattern to match against (e.g. "/user/{id}"). |
| parameters | The parameters to fill with the extracted values from the path. |
Definition at line 134 of file path_matcher.hpp.
|
staticconstexpr |
Definition at line 47 of file path_matcher.hpp.