From 6a7a49fb3804d0d27bbaee08b6feb26b4973b4bc Mon Sep 17 00:00:00 2001 From: niliara-edu Date: Wed, 22 Jan 2025 14:10:08 +0100 Subject: prepare for api --- src/main.rs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 0bd3087..8a64e0d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ +mod api; +mod auth; mod database; -mod routes; mod structs; use actix_web::{web, App, HttpServer}; @@ -9,6 +10,7 @@ use std::sync::Arc; #[derive(Clone)] struct AppState { database: Arc, + secret: String, } #[actix_web::main] @@ -25,25 +27,17 @@ async fn main() -> std::io::Result<()> { }; let db = Arc::new(db_raw); - let app_state = AppState { database: db }; + let app_state = AppState { + database: db, + secret: "secret".to_owned(), + }; HttpServer::new(move || { App::new() .app_data(web::Data::new(app_state.clone())) .route("/", web::get().to(root)) - .service(routes::song::get_song) - .service(routes::song::post_song) - .service(routes::song::put_song) - .service(routes::song::delete_song) - .service(routes::album::get_album) - .service(routes::album::post_album) - .service(routes::album::put_album) - .service(routes::album::delete_album) - .service(routes::artist::get_artist) - .service(routes::artist::post_artist) - .service(routes::artist::put_artist) - .service(routes::artist::delete_artist) - .service(routes::search_results::search_results) + .service(api::api_scope()) + .service(auth::auth_scope()) }) .bind(("127.0.0.1", 8000))? .run() -- cgit v1.2.3