1use warp::{Filter, Rejection};
2use warp_sessions::{MemoryStore, SessionWithStore};
3
4#[tokio::main]
5async fn main() {
6 let session_store = MemoryStore::new();
7
8 let route = warp::get()
9 .and(warp::path!("test"))
10 .and(warp_sessions::request::with_session(session_store, None))
11 .and_then(
12 move |session_with_store: SessionWithStore<MemoryStore>| async move {
13 Ok::<_, Rejection>((
14 warp::reply::html("<html></html>".to_string()),
15 session_with_store,
16 ))
17 },
18 )
19 .untuple_one()
20 .and_then(warp_sessions::reply::with_session);
21
22 let port = 8080;
24 println!("starting server listening on ::{}", port);
25 warp::serve(route).run(([0, 0, 0, 0], port)).await;
26}