Module roa::cookie[][src]

This is supported on crate feature cookies only.

This module provides a middleware cookie_parser and context extensions CookieGetter and CookieSetter.

Example

use roa::cookie::cookie_parser;
use roa::preload::*;
use roa::{App, Context};
use std::error::Error;

async fn end(ctx: &mut Context) -> roa::Result {
    assert_eq!("Hexilee", ctx.must_cookie("name")?.value());
    Ok(())
}

let app = App::new().gate(cookie_parser).end(end);
let (addr, server) = app.run()?;
// server.await
Ok(())

Structs

Cookie

Representation of an HTTP cookie.

Traits

CookieGetter

A context extension. This extension must be used in downstream of middleware cookier_parser, otherwise you cannot get expected cookie.

CookieSetter

An extension to set cookie.

Functions

cookie_parser

A middleware to parse cookie.