#http #web #framework #async

poem-dbsession

Session storage with database for Poem

95 releases

Uses new Rust 2021

0.3.32 Jun 28, 2022
0.3.30 May 15, 2022
0.3.19 Mar 30, 2022
0.2.19 Dec 31, 2021

#14 in WebSocket

Download history 283/week @ 2022-03-14 323/week @ 2022-03-21 78/week @ 2022-03-28 161/week @ 2022-04-04 189/week @ 2022-04-11 47/week @ 2022-04-18 567/week @ 2022-04-25 749/week @ 2022-05-02 145/week @ 2022-05-09 1629/week @ 2022-05-16 384/week @ 2022-05-23 791/week @ 2022-05-30 295/week @ 2022-06-06 144/week @ 2022-06-13 38/week @ 2022-06-20 46/week @ 2022-06-27

709 downloads per month

MIT/Apache

705KB
17K 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–25MB
~474K SLoC