#http #web #framework #async

poem-dbsession

Session storage with database for Poem

117 releases

0.3.55 Feb 18, 2023
0.3.52 Jan 13, 2023
0.3.50 Dec 1, 2022
0.3.49 Nov 21, 2022
0.2.19 Dec 31, 2021

#775 in Asynchronous

Download history 15/week @ 2022-12-02 122/week @ 2022-12-09 4/week @ 2022-12-16 3/week @ 2022-12-23 3/week @ 2022-12-30 45/week @ 2023-01-06 168/week @ 2023-01-13 4/week @ 2023-01-20 13/week @ 2023-01-27 29/week @ 2023-02-03 235/week @ 2023-02-10 278/week @ 2023-02-17 10/week @ 2023-02-24 2/week @ 2023-03-10 237/week @ 2023-03-17

250 downloads per month

MIT/Apache

750KB
18K SLoC

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));

Dependencies

~12–52MB
~1M SLoC