match_request
Macros for creating request routers in hyper.
Request paths can be matched using a more convenient readable syntax, or using full regular expressions. Specific methods can be listed under each path.
The return value of a match can be anything, though you'll usually want to return a boxed function to use as a view.
Pattern syntax
Matching a request path:
use match_request;
use Method;
let path = "/user/home";
let = match_request!.unwrap;
assert_eq!;
Matching against multiple methods:
use match_request;
use Method;
let path = "/example";
let = match_request!.unwrap;
assert_eq!;
Named path parameters:
use match_request;
use Method;
let path = "/posts/2020/my-blog-post";
let = match_request!.unwrap;
assert_eq!;
assert_eq!;
Capturing the path tail:
use match_request;
use Method;
let path = "/static/vendor/img/icon.png";
let = match_request!.unwrap;
// NOTE: the leading `/` is included
assert_eq!;
Example router
use ;
use ;
use ;
// A boxed type definition for your async views.
type BoxedView = ;
// Like a regular `match` expression, `match_request` requires all
// arms to return the same type. As each `async fn` will have a different
// type, you'll likely need to put them in a Box first. This example macro
// is one way to do it.
// An example request router.
async
// Example views...
async
async