1mod extractor;
3
4use extractor::App;
5use spring_boot::async_trait;
6use spring_boot::config::Configurable;
7use spring_boot::{app::AppBuilder, plugin::Plugin};
8use spring_web::{
9 axum::response::{IntoResponse, Json},
10 axum::routing::get,
11 extractor::Component,
12 Router, Routers, WebConfigurator,
13};
14
15#[derive(Configurable)]
16#[config_prefix = "actuator"]
17pub struct ActuatorPlugin;
18
19#[async_trait]
20impl Plugin for ActuatorPlugin {
21 async fn build(&self, app: &mut AppBuilder) {
22 app.add_router(actuator_router());
23 }
24}
25
26fn actuator_router() -> Router {
27 Router::new().nest(
28 "/actuator",
29 Router::new()
30 .route("/health", get("ok"))
31 .route("/endpoints", get(endpoints))
32 .route("/components", get(components)),
33 )
34}
35
36async fn endpoints(Component(routers): Component<Routers>) -> impl IntoResponse {
37 let mut endpoints = vec![];
38 for _r in routers {
39 endpoints.push("");
41 }
42 Json(endpoints)
43}
44
45async fn components(app: App) -> impl IntoResponse {
46 Json(app.get_components())
47}