A cookie manager middleware built on top of [tower].
With [axum]:
```rust use axum::{handler::get, Router}; use std::net::SocketAddr; use tower_cookies::{Cookie, CookieManagerLayer, Cookies};
async fn main() { let app = Router::new() .route("/", get(handler)) .layer(CookieManagerLayer::new());
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
}
async fn handler(cookies: Cookies) -> &'static str { cookies.add(Cookie::new("helloworld", "helloworld"));
"Check your cookies."
} ```
A complete CRUD cookie example in examples/counter.rs
This crate uses #![forbid(unsafe_code)]
to ensure everything is implemented in 100% safe Rust.
We appreciate all kinds of contributions, thank you!
The README.md
file isn't meant to be changed directly. It instead generated from the crate's docs
by the [cargo-readme] command:
cargo install cargo-readme
src/lib.rs
, or wrapping text in README.tpl
cargo readme > README.md
If you have [rusty-hook] installed the changes will apply automatically on commit.
This project is licensed under the MIT license.