Optimize rust database connections

This commit is contained in:
Reimar 2024-08-15 10:10:21 +02:00
parent 707b7b5fce
commit e57174ccda
Signed by: Reimar
GPG Key ID: 93549FA07F0AE268

View File

@ -49,15 +49,12 @@ async fn main() -> std::io::Result<()> {
println!("Starting web server at port {}", port);
HttpServer::new(|| {
let database_path = std::env::var("RUST_BACKEND_DB")
.unwrap_or("database.sqlite3".to_string());
let conn = Arc::new(Mutex::new(rusqlite::Connection::open(database_path).unwrap()));
HttpServer::new(move || {
App::new()
.app_data(web::Data::new(AppData {
database: conn,
database: conn.clone(),
}))
.service(healthcheck)
.service(authorized)