use axum::body::Bytes;
use axum::extract::State;
use axum::response::{IntoResponse, Response};
use crate::server::AppState;
use crate::trust_tasks::{JoinAuthCtx, dispatch_trust_task_core};
#[utoipa::path(
post, path = "/trust-tasks", tag = "trust-tasks",
request_body(
content = String,
description = "A Trust Task document (trust_tasks_rs::TrustTask JSON)",
),
responses(
(status = 200, description = "Trust Task #response document"),
(status = 400, description = "Malformed document / payload (trust-task-error)"),
(status = 403, description = "Holder auth / VIC verification failed (trust-task-error)"),
(status = 422, description = "Task failed, e.g. duplicate request (trust-task-error)"),
),
)]
pub async fn dispatch(State(state): State<AppState>, body: Bytes) -> Response {
dispatch_trust_task_core(&state, &JoinAuthCtx::rest(), &body)
.await
.into_response()
}