License Crates.io Documentation

tower-cookies

A cookie manager middleware built on top of [tower].

Example

With [axum]:

```rust use axum::{routing::get, Router}; use std::net::SocketAddr; use tower_cookies::{Cookie, CookieManagerLayer, Cookies};

[tokio::main]

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

Safety

This crate uses #![forbid(unsafe_code)] to ensure everything is implemented in 100% safe Rust.

Contributing

We appreciate all kinds of contributions, thank you!

Note on README

The README.md file isn't meant to be changed directly. It instead generated from the crate's docs by the [cargo-readme] command:

If you have [rusty-hook] installed the changes will apply automatically on commit.

License

This project is licensed under the MIT license.