-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Hi, I am able to insert a record into session in one handler but unable to retrieve it in another. Could you:
- Put some docs with a how to example
- Let me know how to set the session and store as a layer in Axum
- How to use Redis as the session store
Since docs are not present in this crate currently, I proceeded with docs from async-sessions and got the following errors:
90 | let cookie_value = store.store_session(session).await;
| ^^^^^^^^^^^^^ method not found in Result<RedisSessionStore, redis::types::RedisError>
error[E0599]: no method named load_session found for enum Result in the current scope
--> src/main.rs:91:29
|
91 | let mut session = store.load_session("test-cookie".parse().unwrap()).await.unwrap();
| ^^^^^^^^^^^^ method not found in Result<RedisSessionStore, redis::types::RedisError>
From the following code:
async fn do_something(Extension(session): Extension<Session>) -> Json<Value> {
let store = RedisSessionStore::new("redis://127.0.0.1/");
let cookie_value = store.store_session(session).await;
let mut session = store.load_session("test-cookie".parse().unwrap()).await.unwrap();
let user_id: String = session.get::<String>("user_id").unwrap();
Json(json!({ "data": user_id }))
}
Appreciate any help on this front.