use axum::extract::{Path, State};
use crate::error::AppError;
use crate::server::AppState;
#[utoipa::path(
get, path = "/did/{did}/log", tag = "did-webvh",
params(("did" = String, Path, description = "DID identifier")),
responses(
(status = 200, description = "did.jsonl log", content_type = "text/jsonl"),
(status = 304, description = "Not modified: If-None-Match names the current ETag"),
(status = 429, description = "Rate limited by the VTA (`x-rate-limit-source: vta`)"),
(status = 404, description = "DID not found"),
),
)]
pub async fn get_did_log_public_handler(
State(state): State<AppState>,
Path(did): Path<String>,
headers: axum::http::HeaderMap,
) -> Result<axum::response::Response, AppError> {
let log = crate::webvh_store::get_did_log(&state.webvh_ks, &did).await?;
let log = log.ok_or_else(|| AppError::NotFound(format!("webvh DID log not found: {did}")))?;
Ok(super::self_hosted_did::did_log_response(&headers, log))
}