summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2025-01-21 15:52:44 +0100
committerniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2025-01-21 15:52:44 +0100
commitc277e9937115cc1473219a04199566c7bfdcbaf7 (patch)
treec2806eab444269d92c7c22d1165a9686f5edd9de /src/main.rs
parent58515ddfecd3701112616c33ad4879dae4b38ffd (diff)
get, post, put, delete covered
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs18
1 files changed, 14 insertions, 4 deletions
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))?