1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
mod exporter;
mod list;
mod static_files;

use std::sync::Arc;

use axum::{response::IntoResponse, routing, Router};
use http::StatusCode;

use crate::state::AppState;

pub fn get_app_router(state: Arc<AppState>) -> Router {
    Router::new()
        .route("/", routing::get(list::list_leases))
        .route("/exporter", routing::get(exporter::export_metrics))
        .route("/static/:path", routing::get(static_files::static_files))
        .fallback(handler_404)
        .with_state(state)
}

async fn handler_404() -> impl IntoResponse {
    (StatusCode::NOT_FOUND, "404 Not Found")
}