diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index af45779..9d6ec4f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,10 @@ -mod structs; mod routes; +mod structs; use actix_web::{web, App, HttpServer}; +use dotenv::dotenv; use sqlx::mysql::{MySqlPool, MySqlPoolOptions}; +use std::env; #[derive(Clone)] struct AppState { @@ -11,9 +13,14 @@ struct AppState { #[actix_web::main] async fn main() -> std::io::Result<()> { + dotenv().ok(); let pool: MySqlPool = MySqlPoolOptions::new() .max_connections(10) - .connect(DB_URL) + .connect( + env::var("DATABASE_URL") + .expect("environment variables are *probably not setted up!!") + .as_str(), + ) .await .unwrap(); @@ -23,7 +30,7 @@ async fn main() -> std::io::Result<()> { App::new() .app_data(web::Data::new(app_state.clone())) .route("/", web::get().to(root)) - .service(routes::hello::hello_actix) + .service(routes::song::song) }) .bind(("127.0.0.1", 8000))? .run() |