4
0
Fork 0
mirror of https://github.com/zzzzDev4/ias-tea-axum.git synced 2025-04-21 07:41:21 +02:00

changed routing from POST to PUT where suitable

This commit is contained in:
zzzz 2024-06-16 17:18:40 +02:00
parent df8f7dd184
commit ef5bcb20a5

View file

@ -3,7 +3,7 @@
// cargo shuttle resource list --show-secrets // cargo shuttle resource list --show-secrets
use axum::{ use axum::{
routing::{get, post, delete}, routing::{get, post, put, delete},
Router, Router,
}; };
use axum::http::Method; use axum::http::Method;
@ -27,12 +27,12 @@ async fn main(#[shuttle_shared_db::Postgres] pool: PgPool) -> shuttle_axum::Shut
.nest_service("/", ServeFile::new("assets/index.html")) .nest_service("/", ServeFile::new("assets/index.html"))
// configuration // configuration
.route("/configuration", get(retrieve_config)) .route("/configuration", get(retrieve_config))
.route("/configuration", post(update_config)) .route("/configuration", put(update_config))
// brewing events // brewing events
.route("/brewing-events", get(retrieve_brewing_events)) .route("/brewing-events", get(retrieve_brewing_events))
// types of tea (update tea metadata, no log entry for steeping time) // types of tea (update tea metadata, no log entry for steeping time)
.route("/types-of-tea", get(retrieve_types_of_tea)) .route("/types-of-tea", get(retrieve_types_of_tea))
.route("/types-of-tea/:id", post(update_tea_meta_by_id)) .route("/types-of-tea/:id", put(update_tea_meta_by_id))
.route("/types-of-tea/:id", get(retrieve_tea_by_id)) .route("/types-of-tea/:id", get(retrieve_tea_by_id))
// trigger log entry of steeping time // trigger log entry of steeping time
.route( .route(
@ -46,7 +46,7 @@ async fn main(#[shuttle_shared_db::Postgres] pool: PgPool) -> shuttle_axum::Shut
//.route("/update-tea", post(update_tea_by_rfid)) // probably already covered by "update_tea_by_id" //.route("/update-tea", post(update_tea_by_rfid)) // probably already covered by "update_tea_by_id"
.with_state(state) .with_state(state)
.layer(tower_http::cors::CorsLayer::new() .layer(tower_http::cors::CorsLayer::new()
.allow_methods([Method::GET, Method::POST, Method::DELETE]) .allow_methods([Method::GET, Method::POST, Method::PUT, Method::DELETE])
.allow_origin(tower_http::cors::Any)); .allow_origin(tower_http::cors::Any));
Ok(router.into()) Ok(router.into())