Crate poem_dbsession

source ·
Expand description

Session storage using database for Poem

Crate features

sqlx

featuredatabasetls
sqlx-mysql-rustlsmysqlrustls
sqlx-mysql-native-tlsmysqlnative-tls
sqlx-postgres-rustlspostgresrustls
sqlx-postgres-native-tlspostgresnative-tls
sqlx-sqlite-rustlssqliterustls
sqlx-sqlite-native-tlssqlitenative-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));

Modules

  • sqlx-backed session storages.

Structs