pub fn header<K, V>(name: K, value: V) -> WithHeaderwhere
HeaderName: TryFrom<K>,
<HeaderName as TryFrom<K>>::Error: Into<Error>,
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<Error>,
Expand description
Wrap a Filter
that adds a header to the reply.
§Note
This only adds a header if the underlying filter is successful, and
returns a Reply
If the underlying filter was rejected, the
header is not added.
§Example
use warp::Filter;
// Always set `foo: bar` header.
let route = warp::any()
.map(warp::reply)
.with(warp::reply::with::header("foo", "bar"));