poem-dbsession

Crates.iopoem-dbsession
lib.rspoem-dbsession
version0.3.56
sourcesrc
created_at2021-12-03 00:49:40.687736
updated_at2023-06-06 04:37:05.682162
descriptionSession storage with database for Poem.
homepagehttps://github.com/poem-web/poem
repositoryhttps://github.com/poem-web/poem
max_upload_size
id491488
size27,787
Sunli (sunli829)

documentation

https://docs.rs/poem/

README

Session storage using database for Poem

Crate features

sqlx

feature database tls
sqlx-mysql-rustls mysql rustls
sqlx-mysql-native-tls mysql native-tls
sqlx-postgres-rustls postgres rustls
sqlx-postgres-native-tls postgres native-tls
sqlx-sqlite-rustls sqlite rustls
sqlx-sqlite-native-tls sqlite native-tls

Example

use poem::session::{CookieConfig, ServerSession, Session};
use poem_dbsession::{sqlx::MysqlSessionStorage, DatabaseConfig};
use sqlx::MySqlPool;

#[handler]
fn index(session: &Session) {
    todo!()
}

let pool = MySqlPool::connect("mysql://root:123456@localhost/my_database")
    .await
    .unwrap();
let storage = MysqlSessionStorage::try_new(DatabaseConfig::new(), pool).await.unwrap();
let route = Route::new().at("/", index).with(ServerSession::new(CookieConfig::new(),storage));
Commit count: 1344

cargo fmt