Function finchers_http::path::param
[−]
[src]
pub fn param<T>() -> Param<T> where
T: FromSegment + Send,
Create an endpoint which extracts one segment from the path
and converts it to the value of T
.
If the segments is empty of the conversion to T
is failed,
this endpoint will skip the request.
Example
let endpoint = param() .map_ok(|id: i32| format!("id={}", id)) .unwrap_ok();
Custom handling for the conversion error:
let endpoint = param() .map_err(|_| BadRequest::new("invalid id")) .unwrap_ok() .as_t::<i32>();