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." }