Crates.io | tower-cookies |
lib.rs | tower-cookies |
version | |
source | src |
created_at | 2021-10-15 16:39:58.894577 |
updated_at | 2025-01-01 12:33:31.651399 |
description | Cookie manager middleware for tower. |
homepage | https://github.com/imbolc/tower-cookies |
repository | https://github.com/imbolc/tower-cookies |
max_upload_size | |
id | 465574 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A cookie manager middleware built on top of tower.
With axum:
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));
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}
async fn handler(cookies: Cookies) -> &'static str {
cookies.add(Cookie::new("hello_world", "hello_world"));
"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!
Most of the readme is automatically copied from the crate documentation by cargo-sync-readme. This way the readme is always in sync with the docs and examples are tested.
So if you find a part of the readme you'd like to change between <!-- cargo-sync-readme start -->
and <!-- cargo-sync-readme end -->
markers, don't edit README.md
directly, but rather change
the documentation on top of src/lib.rs
and then synchronize the readme with:
cargo sync-readme
(make sure the cargo command is installed):
cargo install cargo-sync-readme
If you have rusty-hook installed the changes will apply automatically on commit.
This project is licensed under the MIT license.