summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index f1a58ec..5226692 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6,20 +6,26 @@ use actix_web::{web, App, HttpServer};
use dotenv::dotenv;
use std::sync::Arc;
+#[derive(Clone)]
struct AppState {
- database: database::DatabaseWrapper
+ database: Arc<database::DatabaseWrapper>
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
+ // Errors can get very tough,
+ // the rust log saved my ass
+ std::env::set_var("RUST_LOG", "debug");
+ env_logger::init();
dotenv().ok();
- let app_state_raw = database::DatabaseWrapper::new().await.expect("Something went wrong -- DatabaseWrapper::new()");
- let app_state = Arc::new(app_state_raw);
+ let db_raw = database::DatabaseWrapper::new().await.expect("Something went wrong -- DatabaseWrapper::new()");
+ let db = Arc::new(db_raw);
+ let app_state = AppState{database: db};
HttpServer::new(move || {
App::new()
- .app_data(web::Data::new(Arc::clone(&app_state)))
+ .app_data(web::Data::new(app_state.clone()))
.route("/", web::get().to(root))
.service(routes::song::song)
.service(routes::album::album)