diff --git a/src/config/health_check/mod.rs b/src/config/health_check/mod.rs index 0cad9037..dccebf1c 100644 --- a/src/config/health_check/mod.rs +++ b/src/config/health_check/mod.rs @@ -1,7 +1,9 @@ use crate::app::context::AppContext; +use crate::config::app_config::CustomConfig; use crate::util::serde_util::default_true; use config::{FileFormat, FileSourceString}; use serde_derive::{Deserialize, Serialize}; +use std::collections::BTreeMap; use validator::Validate; pub fn default_config() -> config::File { @@ -18,6 +20,33 @@ pub struct HealthCheck { pub database: HealthCheckConfig<()>, #[cfg(feature = "sidekiq")] pub sidekiq: HealthCheckConfig<()>, + /// Allows providing configs for custom health checks. Any configs that aren't pre-defined above + /// will be collected here. + /// + /// # Examples + /// + /// ```toml + /// [health-check.foo] + /// enable = true + /// x = "y" + /// ``` + /// + /// This will be parsed as: + /// ```raw + /// HealthCheck#custom: { + /// "foo": { + /// HealthCheckConfig#common: { + /// enable: true, + /// priority: 10 + /// }, + /// HealthCheckConfig#custom: { + /// "x": "y" + /// } + /// } + /// } + /// ``` + #[serde(flatten)] + pub custom: BTreeMap>, } #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/src/config/service/http/initializer.rs b/src/config/service/http/initializer.rs index 16d75076..59ce0a28 100644 --- a/src/config/service/http/initializer.rs +++ b/src/config/service/http/initializer.rs @@ -38,9 +38,7 @@ pub struct Initializer { /// priority: 10 /// }, /// InitializerConfig#custom: { - /// config: { - /// "x": "y" - /// } + /// "x": "y" /// } /// } /// } diff --git a/src/config/service/http/middleware.rs b/src/config/service/http/middleware.rs index 21966d20..2082e46e 100644 --- a/src/config/service/http/middleware.rs +++ b/src/config/service/http/middleware.rs @@ -70,9 +70,7 @@ pub struct Middleware { /// priority: 10 /// }, /// MiddlewareConfig#custom: { - /// config: { - /// "x": "y" - /// } + /// "x": "y" /// } /// } /// }