From e57174ccda9d3ba3f53c4467bce92a6bb932081b Mon Sep 17 00:00:00 2001 From: Reimar Date: Thu, 15 Aug 2024 10:10:21 +0200 Subject: [PATCH] Optimize rust database connections --- rust-backend/src/main.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/rust-backend/src/main.rs b/rust-backend/src/main.rs index 1322e98..f5f5d38 100644 --- a/rust-backend/src/main.rs +++ b/rust-backend/src/main.rs @@ -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())); + 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)