add flow api route

This commit is contained in:
JMARyA 2024-09-23 16:37:18 +02:00
parent 65bfb5f8e2
commit 9135c2f913
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
2 changed files with 10 additions and 1 deletions

View file

@ -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)

View file

@ -142,6 +142,14 @@ pub async fn create_flow_route(
Ok(json!({"uuid": flow._id }))
}
#[get("/flow/<id>")]
pub async fn flow_api_route(id: &str, flows: &State<JSONStore<FlowInfo>>) -> FallibleApiResponse {
let flow = Flow::get(id)
.await
.ok_or_else(|| api_error("No such flow"))?;
Ok(flow.api().await)
}
#[post("/flow/<id>/end", data = "<form>")]
pub async fn end_flow_route(id: &str, form: Json<EndFlow>) -> FallibleApiResponse {
let flow = Flow::get(id)