Expand description
Route matching.
The Router owns the compiled set of mock routes and answers the
question “given this request, which route matches and what should the
response be?”.
§Matching algorithm
Routes are evaluated in declaration order; the first matching route wins. A route matches when:
- the HTTP
Methodequals the request method, - the path pattern matches the request path segment by segment
(capturing
{param}segments), and - every rule in the optional
whenblock (RequestMatch) is satisfied: required query parameters, headers (case-insensitively) and a JSON body subset.
Structs§
- Match
- The result of matching a request against the
Router. - Router
- A compiled set of routes ready to answer requests.
Enums§
- Path
Error - Errors in an individual path pattern.
- Router
Error - Errors that can occur while building a
Router.