mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-08-06 17:40:59 +00:00
re-add well-known table, while still allowing individual values to be set with env vars without double underscores
This commit is contained in:
parent
a9ff97e527
commit
de323cbecb
4 changed files with 26 additions and 13 deletions
|
@ -59,7 +59,7 @@ pub struct Config {
|
|||
pub allow_unstable_room_versions: bool,
|
||||
#[serde(default = "default_default_room_version")]
|
||||
pub default_room_version: RoomVersionId,
|
||||
#[serde(default, flatten)]
|
||||
#[serde(default)]
|
||||
pub well_known: WellKnownConfig,
|
||||
#[serde(default = "false_fn")]
|
||||
pub allow_jaeger: bool,
|
||||
|
@ -97,9 +97,7 @@ pub struct TlsConfig {
|
|||
|
||||
#[derive(Clone, Debug, Deserialize, Default)]
|
||||
pub struct WellKnownConfig {
|
||||
#[serde(rename = "well_known_client")]
|
||||
pub client: Option<Url>,
|
||||
#[serde(rename = "well_known_server")]
|
||||
pub server: Option<OwnedServerName>,
|
||||
}
|
||||
|
||||
|
|
18
src/main.rs
18
src/main.rs
|
@ -12,6 +12,7 @@ use axum_server::{bind, bind_rustls, tls_rustls::RustlsConfig, Handle as ServerH
|
|||
use conduit::api::{client_server, server_server};
|
||||
use figment::{
|
||||
providers::{Env, Format, Toml},
|
||||
value::Uncased,
|
||||
Figment,
|
||||
};
|
||||
use http::{
|
||||
|
@ -44,6 +45,8 @@ use tikv_jemallocator::Jemalloc;
|
|||
#[global_allocator]
|
||||
static GLOBAL: Jemalloc = Jemalloc;
|
||||
|
||||
static SUB_TABLES: [&str; 2] = ["well_known", "tls"]; // Not doing `proxy` cause setting that with env vars would be a pain
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
clap::parse();
|
||||
|
@ -57,7 +60,20 @@ async fn main() {
|
|||
))
|
||||
.nested(),
|
||||
)
|
||||
.merge(Env::prefixed("CONDUIT_").global().split("__"));
|
||||
.merge(Env::prefixed("CONDUIT_").global().map(|k| {
|
||||
let mut key: Uncased = k.into();
|
||||
|
||||
for table in SUB_TABLES {
|
||||
if k.starts_with(&(table.to_owned() + "_")) {
|
||||
key = Uncased::from(
|
||||
table.to_owned() + "." + k[table.len() + 1..k.len()].as_str(),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
key
|
||||
}));
|
||||
|
||||
let config = match raw_config.extract::<Config>() {
|
||||
Ok(s) => s,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue