Skip to main content

objectstore_server/endpoints/
mod.rs

1//! Contains all HTTP endpoint handlers.
2//!
3//! Use [`routes`] to create a router with all endpoints.
4
5use axum::Router;
6
7use crate::state::ServiceState;
8
9mod batch;
10pub mod common;
11pub mod health;
12mod keda;
13mod multipart;
14mod objects;
15#[cfg(all(target_os = "linux", feature = "profiling"))]
16mod profiling;
17
18/// Returns `true` for internal endpoints that are exempt from metrics and concurrency limits.
19pub fn is_internal_route(route: &str) -> bool {
20    matches!(route, "/health" | "/ready" | "/keda") || route.starts_with("/debug/")
21}
22
23/// Returns a router with all objectstore HTTP endpoints mounted.
24///
25/// Mounts health and KEDA endpoints at the root and all object/batch
26/// endpoints under `/v1/`.
27pub fn routes() -> Router<ServiceState> {
28    let routes_v1 = Router::new()
29        .merge(objects::router())
30        .merge(batch::router())
31        .merge(multipart::router());
32
33    let router = Router::new()
34        .merge(health::router())
35        .merge(keda::router())
36        .nest("/v1/", routes_v1);
37
38    std::cfg_select! {
39        all(target_os = "linux", feature = "profiling") => {
40            router.merge(profiling::router())
41        }
42        _ => { router }
43    }
44}