[−][src]Function hyperbole::mw::cookie_opt
pub fn cookie_opt<const NAME: &'static str>(
cx: HCons<HeaderMap, HNil>
) -> HCons<Field<Option<String>, NAME>, HCons<HeaderMap, HNil>>
Extract an optional cookie from the request context. The cookie name should be passed via const generic parameter.
The extracted cookie will be injected into the context as a named field.
Use with Ctx::map
.
Examples
use hyperbole::{mw, Ctx, R}; let _ctx = Ctx::default().map(mw::cookie_opt::<"some_cookie">).map( |cx: R![some_cookie: Option<String>]| { println!("cookie value is {:?}", cx.head); cx }, );