cookie-monster
A Cookie library for parsing and managing HTTP Cookies.
Features
jiff, adds support for the jiff crate.chrono, adds support for the chrono crate.time, adds support for the time crate.percent-encode, percent-encode/decode cookies.axum, adds integration with the axum crate.http, adds integration with the http crate.
Install
# Cargo.toml
[]
= "0.1"
# Integration with the `time` crate
= { = "0.1", = ["time"] }
# Integration with the`chrono` crate
= { = "0.1", = ["chrono"] }
# Integration with the `jiff` crate
= { = "0.1", = ["jiff"] }
# Adds support for percent-encoding/decoding cookies.
= { = "0.1", = ["percent-encoding"] }
# Integration with the `axum` crate.
= { = "0.1", = ["axum"] }
# Integration with the `http` crate.
= { = "0.1", = ["http"] }
Axum example
use IntoResponse;
use ;
static COOKIE_NAME: &str = "session";
async
Prefix cookies
Cookie::host and Cookie::secure build cookies using the __Host- and __Secure- name
prefixes (RFC 6265bis §4.1.3). They set the attributes the prefix requires as defaults (which
you can override to build non-standard cookies) and apply the prefix to the name on
serialization. Parsing strips a recognized prefix from the name, so a prefixed cookie is looked
up in a CookieJar by its logical (unprefixed) name.
use Cookie;
let cookie = host.build;
assert_eq!;
assert_eq!;
Minimum Supported Rust Version (MSRV)
The cookie-monster crate has rust version 1.85 as MSRV.
Honorable mention
This crate takes a lot of inspiration from the cookie crate.
License
This project is licensed under the MIT license.