diff --git a/backend/windmill-api/src/jobs.rs b/backend/windmill-api/src/jobs.rs index ce1e681c92..3b7205d6ae 100644 --- a/backend/windmill-api/src/jobs.rs +++ b/backend/windmill-api/src/jobs.rs @@ -54,11 +54,9 @@ pub fn workspaced_service() -> Router { ) .route( "/run_wait_result/p/*script_path", - post(run_wait_result_script_by_path).head(|| async { "" }), - ) - .route( - "/run_wait_result/p/*script_path", - get(run_wait_result_job_by_path_get), + post(run_wait_result_script_by_path) + .get(run_wait_result_job_by_path_get) + .head(|| async { "" }), ) .route( "/run_wait_result/h/:hash", @@ -66,7 +64,9 @@ pub fn workspaced_service() -> Router { ) .route( "/run_wait_result/f/*script_path", - post(run_wait_result_flow_by_path).head(|| async { "" }), + post(run_wait_result_flow_by_path) + .get(run_wait_result_flow_by_path_get) + .head(|| async { "" }), ) .route( "/openai_sync/p/*script_path", @@ -1733,6 +1733,45 @@ pub async fn run_wait_result_job_by_path_get( .await } +pub async fn run_wait_result_flow_by_path_get( + method: hyper::http::Method, + authed: Authed, + Extension(rsmq): Extension>, + Extension(user_db): Extension, + Extension(db): Extension, + Path((w_id, flow_path)): Path<(String, StripPath)>, + headers: HeaderMap, + Query(run_query): Query, +) -> error::JsonResult { + if method == http::Method::HEAD { + return Ok(Json(serde_json::json!(""))); + } + let payload_r = run_query + .payload + .clone() + .map(decode_payload) + .map(|x| x.map_err(|e| Error::InternalErr(e.to_string()))); + + let args = if let Some(payload) = payload_r { + payload? + } else { + serde_json::Map::new() + }; + run_wait_result_flow_by_path_internal( + db, + run_query, + flow_path, + authed, + rsmq, + user_db, + headers, + Some(args), + None, + w_id, + ) + .await +} + pub async fn run_wait_result_script_by_path( authed: Authed, Extension(user_db): Extension,