pub trait CookieExt: Sealed + Sized {
    fn cookies(&self) -> Option<&CookieJar> { ... }
fn cookies_mut(&mut self) -> &mut CookieJar { ... }
fn with_cookies(self, jar: CookieJar) -> Self { ... }
fn cookie(&self, name: &str) -> Option<&str> { ... }
fn add_cookie(&mut self, cookie: Cookie<'static>) { ... }
fn with_cookie(self, cookie: Cookie<'static>) -> Self { ... } }
Expand description

A trait for types that have cookies. This allows interfacing with their cookie jars.

Provided methods

Returns the extracted cookie jar. If no cookie jar had been extracted (i.e., the CookieMiddleware was not used), then this will return None.

Examples
use under::middleware::CookieExt;
let request = Request::get("/").unwrap();
assert!(request.cookies().is_none());
let request = request.with_cookies(Default::default());
assert!(request.cookies().is_some());

Returns the mutable cookie jar. If no cookie jar had been extracted (i.e. the CookieMiddleware was not used), then this will return an empty cookie jar.

Examples
use under::middleware::CookieExt;
let mut request = Request::get("/").unwrap();
assert!(request.cookies_mut().iter().count() == 0);

Returns self with the given cookie jar. This replaces (and drops) the current cookie jar, if one exists.

Examples
use under::middleware::CookieExt;
let request = Request::get("/").unwrap();
assert!(request.cookies().is_none());
let request = request.with_cookies(Default::default());
assert!(request.cookies().is_some());

Returns the value for the cookie with the given name. If no cookie jar is set, it returns None; if no cookie with the given name exists, it returns None; otherwise, it returns its value.

Examples
use under::middleware::CookieExt;
let mut request = Request::get("/").unwrap();
assert!(request.cookie("foo").is_none());
request.cookies_mut().add(Cookie::new("foo", "bar"));
assert_eq!(request.cookie("foo"), Some("bar"));

Adds the given cookie to the current cookie jar. This addition does add to the delta, and creates the cookie jar if it does not exist.

Examples
use under::middleware::CookieExt;
let mut request = Request::get("/").unwrap();
assert!(request.cookie("foo").is_none());
request.add_cookie(Cookie::new("foo", "bar"));
assert_eq!(request.cookie("foo"), Some("bar"));

Adds the given cookie to the cookie jar. This is essentially the same as Self::add_cookie.

Implementors