use actix_web::{HttpResponse, Responder, get, web::Data};
pub mod admin;
pub mod auth;
pub mod backup;
pub mod cache;
pub mod client_context;
pub mod error;
pub mod gateway;
pub mod headers;
pub mod health;
pub mod host_routing;
pub mod management;
pub mod metrics;
pub mod pg_meta;
pub mod pipelines;
pub mod provision;
pub mod public_routes;
pub mod query;
pub mod registry;
pub mod response;
pub mod schema;
pub mod storage;
pub mod supabase;
pub use error::{ApiError, ApiResult};
use crate::AppState;
use crate::data::athena_router::list_athena_router_entries;
use client_context::logging_pool;
use response::{api_ok, internal_error};
const OPENAPI_YAML: &str = include_str!("../../openapi.yaml");
const OPENAPI_WSS_YAML: &str = include_str!("../../openapi-wss.yaml");
#[get("/router/registry")]
pub async fn athena_router_registry(state: Data<AppState>) -> impl Responder {
let pool: sqlx::Pool<sqlx::Postgres> = match logging_pool(&state) {
Ok(pool) => pool,
Err(resp) => return resp,
};
match list_athena_router_entries(&pool).await {
Ok(entries) => api_ok(entries),
Err(err) => internal_error("Failed to list router entries", err),
}
}
#[get("/openapi.yaml")]
pub async fn athena_openapi_host() -> impl Responder {
HttpResponse::Ok()
.content_type("application/yaml; charset=utf-8")
.body(OPENAPI_YAML)
}
#[get("/openapi-wss.yaml")]
pub async fn athena_wss_openapi_host() -> impl Responder {
HttpResponse::Ok()
.content_type("application/yaml; charset=utf-8")
.body(OPENAPI_WSS_YAML)
}
#[get("/docs")]
pub async fn athena_docs() -> impl Responder {
actix_web::HttpResponse::PermanentRedirect()
.insert_header(("Location", "https://xylex.group/docs/athena"))
.finish()
}