[][src]Function hyperbole::mw::header

pub fn header(
    name: HeaderName
) -> impl Fn(HCons<HeaderMap, HNil>) -> Result<HCons<HeaderValue, HCons<HeaderMap, HNil>>, HeaderError>

Extract a HeaderValue from the request context by name.

This is generally less useful than typed_header because only a single HeaderValue can exist in a context at a time.

Use with Ctx::try_map.

Examples

use hyper::header::{HeaderValue, ACCEPT};
use hyperbole::{mw, Ctx, R};

let _ctx = Ctx::default()
    .try_map(mw::header(ACCEPT))
    .map(|cx: R![HeaderValue]| cx);