Function warp::filters::reply::default_header
source · pub fn default_header<K, V>(name: K, value: V) -> WithDefaultHeaderwhere
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, if they
aren’t already set.
§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;
// Set `server: warp` if not already set.
let route = warp::any()
.map(warp::reply)
.with(warp::reply::with::default_header("server", "warp"));