[][src]Function hyperbole::mw::header_opt

pub fn header_opt(
    name: HeaderName
) -> impl Fn(HCons<HeaderMap, HNil>) -> HCons<Option<HeaderValue>, HCons<HeaderMap, HNil>>

Extract an optional HeaderValue from the request context by name.

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

Use with Ctx::map.

Examples

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

let _ctx = Ctx::default()
    .map(mw::header_opt(ACCEPT))
    .map(|cx: R![Option<HeaderValue>]| cx);