mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Scanner status handlers all derived operationId "status" from their fn name, so Swagger UI's "Try it out" executed the first one (ARP) — the DHCP doc hit /api/arp_scanner/status. Same collision for read/list/ register/unregister. Each path now sets an explicit unique operation_id. main's tokio::join!(...).0 kept only the ARP result and silently dropped the other tasks' errors, so a DHCP scanner that failed to bind port 67 just showed "off" with no log. Each task is now wrapped to log its error. Fixes #5
43 lines
1021 B
Rust
43 lines
1021 B
Rust
use axum::Json;
|
|
|
|
use crate::model::config::{Config, NotificationConfig};
|
|
use crate::settings::get_settings;
|
|
|
|
#[utoipa::path(
|
|
get,
|
|
path = "/api/config",
|
|
operation_id = "config_read",
|
|
tag = "config",
|
|
responses(
|
|
(status = 200, description = "Front-end configuration", body = Config),
|
|
),
|
|
security(("bearer_auth" = []))
|
|
)]
|
|
pub async fn read() -> Json<Config> {
|
|
let settings = get_settings();
|
|
Json(Config {
|
|
notifications: NotificationConfig {
|
|
method: settings.notifications.method.clone(),
|
|
},
|
|
})
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use crate::tests_common;
|
|
|
|
#[tokio::test]
|
|
async fn config_reports_the_configured_notification_method() {
|
|
tests_common::setup().await;
|
|
|
|
let Json(config) = read().await;
|
|
|
|
assert_eq!(
|
|
config.notifications.method,
|
|
get_settings().notifications.method,
|
|
"The endpoint should echo the backend's configured notification method"
|
|
);
|
|
}
|
|
}
|