// Invoke-WebRequest -Uri https://ias-tea-axum.shuttleapp.rs/addtea -Method POST -Body '{ "teaname": DemoTea, "rfidcode": "lo1rfId42", "watertemp": 200, "steepingseconds": 10}' -ContentType 'application/json' // cargo shuttle resource delete database::shared::postgres // cargo shuttle resource list --show-secrets use axum::{ routing::{get, post}, Router, }; use data::MyState; use sqlx::PgPool; use tower_http::services::ServeFile; mod data; mod requests; use crate::requests::{get_requests::*, post_requests::*}; #[shuttle_runtime::main] async fn main(#[shuttle_shared_db::Postgres] pool: PgPool) -> shuttle_axum::ShuttleAxum { sqlx::migrate!() .run(&pool) .await .expect("Failed to run migrations"); let state = MyState { pool }; let router = Router::new() .nest_service("/", ServeFile::new("assets/index.html")) // configuration .route("/configuration", get(retrieve_config)) .route("/configuration", post(update_config)) // brewing events .route("/brewing-events", get(retrieve_brewing_events)) // 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", get(retrieve_tea_by_id)) // update steeping time and trigger log entry .route( "/tea-steeping-time/:id", post(update_tea_steeping_time_by_id), ) // teavail-device .route("/tea-by-rfid/:rfid", get(retrieve_tea_by_rfid)) .route("/add-tea", post(add_tea)) .route("/delete-tea", get(delete_tea_by_id)) //.route("/update-tea", post(update_tea_by_rfid)) // probably already covered by "update_tea_by_id" .with_state(state); Ok(router.into()) }