26 lines
697 B
Rust
26 lines
697 B
Rust
mod auth;
|
|
mod health;
|
|
mod openapi;
|
|
mod restricted;
|
|
|
|
use std::sync::Arc;
|
|
|
|
use crate::routes::AppState;
|
|
|
|
pub use self::openapi::ApiDoc;
|
|
|
|
use axum::{Router, response::IntoResponse, routing::any};
|
|
|
|
pub fn get_api_router(state: Arc<AppState>) -> Router {
|
|
Router::new()
|
|
.nest("/health", health::get_health_router())
|
|
.merge(auth::get_basic_auth_router(state.clone()))
|
|
.merge(restricted::get_restricted_router(state.clone()))
|
|
// explicit fallback for unmatched API routes
|
|
.route("/{*wildcard}", any(api_fallback_handler))
|
|
}
|
|
|
|
async fn api_fallback_handler() -> impl IntoResponse {
|
|
(axum::http::StatusCode::NOT_FOUND, "API route not found").into_response()
|
|
}
|