From c277e9937115cc1473219a04199566c7bfdcbaf7 Mon Sep 17 00:00:00 2001 From: niliara-edu Date: Tue, 21 Jan 2025 15:52:44 +0100 Subject: get, post, put, delete covered --- src/main.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index f55a17c..0bd3087 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,9 +19,11 @@ async fn main() -> std::io::Result<()> { env_logger::init(); dotenv().ok(); - let db_raw = database::DatabaseWrapper::new() - .await - .expect("Something went wrong while creating DatabaseWrapper"); + let db_raw = match database::DatabaseWrapper::new().await { + Ok(res) => res, + Err(_) => panic!("Error creating database wrapper"), + }; + let db = Arc::new(db_raw); let app_state = AppState { database: db }; @@ -30,9 +32,17 @@ async fn main() -> std::io::Result<()> { .app_data(web::Data::new(app_state.clone())) .route("/", web::get().to(root)) .service(routes::song::get_song) - .service(routes::album::album) + .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) }) .bind(("127.0.0.1", 8000))? -- cgit v1.2.3