[][src]Function warp::filters::reply::header

pub fn header<K, V>(name: K, value: V) -> WithHeader where
    HeaderName: HttpTryFrom<K>,
    HeaderValue: HttpTryFrom<V>, 

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"));