#include <Router.h>
Public Member Functions | |
Route (const RegularExpression &verbMatch, const RegularExpression &pathMatch, const RequestHandler &handler) | |
nonvirtual bool | Matches (const Request &request, Sequence< String > *pathRegExpMatches=nullptr) const |
&&& HEAD and OPTIONS can have routes to be overridden. But by default they are handled automatically by the router.
@todo - we probably want to add ability to generically parse out arguments from url, and include them to handler (as rails does - handy for ID in REST) @todo need more generic matching to fit in (maybe optional matcher that takes URL?, or even full Request). NOTE - may verb match and path match each OPTIONALS in class and have maybe a LIST of THINGS we know how to match. VERB RELPATH HTTP HEADER (like SOAPACTION) RequestObject???? then we use "Route" to make generic the mapping of a request to a Handler. @todo NEED to support NESTED Routes (or aggregated). Key is need stuff like 'default error handling' - and just to somehow inherit/copy that. (reconsider - maybe easy now that I have 'handled' flag)...
Stroika::Frameworks::WebServer::Route::Route | ( | const RegularExpression & | verbMatch, |
const RegularExpression & | pathMatch, | ||
const RequestHandler & | handler | ||
) |
Any route to apply the handler, must match ALL argument constraints. If verbMatch is omitted, it it assumed to be IO::Network::HTTP::MethodsRegEx::kGet (NOT RegularExpression::kAny)
Definition at line 13 of file Router.inl.
bool Route::Matches | ( | const Request & | request, |
Sequence< String > * | pathRegExpMatches = nullptr |
||
) | const |
Check if the given request matches this Route. Overload taking method/hostRelPath can be derived from request, but can be substituted with different values. Overload with optional matches returns variable matches in the regexp for the path
We interpret routes as matching against a relative path from the root
Definition at line 54 of file Router.cpp.