#http #web #framework #async

poem-dbsession

Session storage with database for Poem

46 releases

Uses new Rust 2021

new 0.2.42 Jan 22, 2022
0.2.41 Jan 21, 2022
0.2.19 Dec 31, 2021
0.1.6 Dec 13, 2021

#19 in WebSocket

Download history 40/week @ 2021-11-27 40/week @ 2021-12-04 115/week @ 2021-12-11 71/week @ 2021-12-18 135/week @ 2021-12-25 142/week @ 2022-01-01 168/week @ 2022-01-08 113/week @ 2022-01-15

565 downloads per month

MIT/Apache

605KB
14K 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

~11–20MB
~401K SLoC

ga