From 533708f885c3a0aaae3785d833204efee5cc8c71 Mon Sep 17 00:00:00 2001 From: Alexey <247128645+axkurcom@users.noreply.github.com> Date: Wed, 4 Mar 2026 01:08:59 +0300 Subject: [PATCH] API in defaults Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com> --- src/config/types.rs | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/config/types.rs b/src/config/types.rs index 64be729..dfb6b89 100644 --- a/src/config/types.rs +++ b/src/config/types.rs @@ -793,6 +793,48 @@ impl Default for LinksConfig { } } +/// API settings for control-plane endpoints. +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +pub struct ApiConfig { + /// Enable or disable REST API. + #[serde(default)] + pub enabled: bool, + + /// Listen address for API in `IP:PORT` format. + #[serde(default = "default_api_listen")] + pub listen: String, + + /// CIDR whitelist allowed to access API. + #[serde(default = "default_api_whitelist")] + pub whitelist: Vec, + + /// Optional static value for `Authorization` header validation. + /// Empty string disables header auth. + #[serde(default)] + pub auth_header: String, + + /// Maximum accepted HTTP request body size in bytes. + #[serde(default = "default_api_request_body_limit_bytes")] + pub request_body_limit_bytes: usize, + + /// Read-only mode: mutating endpoints are rejected. + #[serde(default)] + pub read_only: bool, +} + +impl Default for ApiConfig { + fn default() -> Self { + Self { + enabled: false, + listen: default_api_listen(), + whitelist: default_api_whitelist(), + auth_header: String::new(), + request_body_limit_bytes: default_api_request_body_limit_bytes(), + read_only: false, + } + } +} + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ServerConfig { #[serde(default = "default_port")] @@ -828,6 +870,9 @@ pub struct ServerConfig { #[serde(default = "default_metrics_whitelist")] pub metrics_whitelist: Vec, + #[serde(default, alias = "admin_api")] + pub api: ApiConfig, + #[serde(default)] pub listeners: Vec, } @@ -844,6 +889,7 @@ impl Default for ServerConfig { proxy_protocol: false, metrics_port: None, metrics_whitelist: default_metrics_whitelist(), + api: ApiConfig::default(), listeners: Vec::new(), } }