From 9135c2f913673082dcc35e62bc00a2139c56395a Mon Sep 17 00:00:00 2001 From: JMARyA Date: Mon, 23 Sep 2024 16:37:18 +0200 Subject: [PATCH] add flow api route --- src/main.rs | 3 ++- src/routes/flow.rs | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index ef8bbc3..1095c1d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -93,7 +93,8 @@ async fn rocket() -> _ { routes::item::move_transaction_route, routes::item::variant_price_latest_by_origin, routes::item::item_stat_route, - routes::flow::active_flows_route + routes::flow::active_flows_route, + routes::flow::flow_api_route ], ) .manage(itemdb) diff --git a/src/routes/flow.rs b/src/routes/flow.rs index d2a3dea..7ac2600 100644 --- a/src/routes/flow.rs +++ b/src/routes/flow.rs @@ -142,6 +142,14 @@ pub async fn create_flow_route( Ok(json!({"uuid": flow._id })) } +#[get("/flow/")] +pub async fn flow_api_route(id: &str, flows: &State>) -> FallibleApiResponse { + let flow = Flow::get(id) + .await + .ok_or_else(|| api_error("No such flow"))?; + Ok(flow.api().await) +} + #[post("/flow//end", data = "
")] pub async fn end_flow_route(id: &str, form: Json) -> FallibleApiResponse { let flow = Flow::get(id)