summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-11-12 20:53:18 +0100
committerniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-11-12 20:53:18 +0100
commit6a762589e2f557cb1b2096c6e8d888129c3e2fca (patch)
tree09f779034fa564f3b97d9fe86158b2f3acb887e1 /src/main.rs
parent6d57e0d0da0bbe5461acfb0b1809f5d22a5b4fcc (diff)
basic routing for songs
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs13
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()