use axum::extract::{Request, State};
use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
#[cfg(feature = "method-web")]
use super::resolve_web;
#[cfg(feature = "method-webvh")]
use super::resolve_webvh;
use crate::server::AppState;
#[cfg_attr(feature = "openapi", utoipa::path(
get,
path = "/{mnemonic}/did.jsonl",
tag = "resolve",
params(("mnemonic" = String, Path, description = "Slot path; the published did:webvh resolves at <base>/{mnemonic}/did.jsonl")),
responses(
(status = 200, description = "did:webvh log (JSONL) or did:web document for the slot", content_type = "application/jsonl+json"),
(status = 404, description = "No DID hosted at this path"),
),
))]
pub async fn serve_public(State(state): State<AppState>, request: Request) -> Response {
let (parts, _) = request.into_parts();
#[cfg(feature = "method-webvh")]
{
if let Some(response) = resolve_webvh::dispatch(&state, &parts).await {
return response;
}
}
#[cfg(feature = "method-web")]
{
if let Some(response) = resolve_web::dispatch(&state, &parts).await {
return response;
}
}
let _ = state;
let _ = parts;
StatusCode::NOT_FOUND.into_response()
}