#http #web #framework #async

poem-dbsession

Session storage with database for Poem

118 releases

0.3.56 Jun 6, 2023
0.3.55 Feb 18, 2023
0.3.52 Jan 13, 2023
0.3.50 Dec 1, 2022
0.2.19 Dec 31, 2021

#230 in WebSocket

Download history 15/week @ 2023-10-22 176/week @ 2023-10-29 9/week @ 2023-11-05 121/week @ 2023-11-12 1/week @ 2023-11-19 238/week @ 2023-11-26 336/week @ 2023-12-03 1/week @ 2023-12-10 118/week @ 2023-12-17 236/week @ 2023-12-24 118/week @ 2023-12-31 1/week @ 2024-01-14 101/week @ 2024-01-21 236/week @ 2024-01-28

338 downloads per month

MIT/Apache

770KB
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

~14–35MB
~580K SLoC