pub fn optional<T>(
name: &'static str,
) -> impl Filter<Extract = (Option<T>,), Error = Rejection> + Copy
Expand description
Create a Filter
that tries to parse the specified header, if it exists.
If the header does not exist, it yields None
. Otherwise, it will try to
parse as a T
, and if it fails, a invalid header rejection is return. If
successful, the filter yields Some(T)
.
§Example
// Grab the `authorization` header if it exists.
let opt_auth = warp::header::optional::<String>("authorization");