diff --git a/src/servers/src/http.rs b/src/servers/src/http.rs index c292b5dfb4..cd1901e318 100644 --- a/src/servers/src/http.rs +++ b/src/servers/src/http.rs @@ -11,6 +11,7 @@ use aide::axum::routing as apirouting; use aide::axum::{ApiRouter, IntoApiResponse}; use aide::openapi::{Info, OpenApi}; use async_trait::async_trait; +use axum::response::Html; use axum::Extension; use axum::{error_handling::HandleErrorLayer, response::Json, routing, BoxError, Router}; use common_query::Output; @@ -204,10 +205,14 @@ async fn shutdown_signal() { .expect("failed to install CTRL+C signal handler"); } -async fn serve_api(Extension(api): Extension) -> impl IntoApiResponse { +async fn serve_api(Extension(api): Extension>) -> impl IntoApiResponse { Json(api) } +async fn serve_docs() -> Html { + Html(include_str!("http/redoc.html").to_owned()) +} + impl HttpServer { pub fn new(sql_handler: SqlQueryHandlerRef) -> Self { Self { @@ -269,6 +274,7 @@ impl HttpServer { .api_route("/scripts", apirouting::post(handler::scripts)) .api_route("/run-script", apirouting::post(handler::run_script)) .route("/private/api.json", apirouting::get(serve_api)) + .route("/private/docs", apirouting::get(serve_docs)) .finish_api(&mut api) .layer(Extension(Arc::new(api))); diff --git a/src/servers/src/http/redoc.html b/src/servers/src/http/redoc.html new file mode 100644 index 0000000000..8e97598b12 --- /dev/null +++ b/src/servers/src/http/redoc.html @@ -0,0 +1,27 @@ + + + + Redoc + + + + + + + + + + + + +