fix: add sync method for flows

This commit is contained in:
Ruben Fiszel
2023-07-28 15:45:28 +02:00
parent adea8ff1b4
commit e03da23f17
+45 -6
View File
@@ -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<Option<rsmq_async::MultiplexedRsmq>>,
Extension(user_db): Extension<UserDB>,
Extension(db): Extension<DB>,
Path((w_id, flow_path)): Path<(String, StripPath)>,
headers: HeaderMap,
Query(run_query): Query<RunJobQuery>,
) -> error::JsonResult<serde_json::Value> {
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<UserDB>,