Macro warp::path [−][src]
macro_rules! path { (@start $first:tt $(/ $tail:tt)*) => { ... }; (@segment $param:ty) => { ... }; (@segment $s:expr) => { ... }; ($($pieces:tt)*) => { ... }; }
Convenient way to chain multiple path filters together.
Any number of either type identifiers or string expressions can be passed,
each separated by a forward slash (/
). Strings will be used to match
path segments exactly, and type identifiers are used just like
param
filters.
Example
use warp::Filter; // Match `/sum/:a/:b` let route = path!("sum" / u32 / u32) .map(|a, b| { format!("{} + {} = {}", a, b, a + b) });
The equivalent filter chain without using the path!
macro looks this:
use warp::Filter; let route = warp::path("sum") .and(warp::path::param::<u32>()) .and(warp::path::param::<u32>()) .map(|a, b| { format!("{} + {} = {}", a, b, a + b) });
In fact, this is exactly what the macro expands to.