Renamed STALWART_BASE_URL to STALWART_HTTP_PORT
This commit is contained in:
@@ -428,12 +428,20 @@ impl Http {
|
||||
|
||||
Http {
|
||||
url_https: if !bp.registry.is_bootstrap_mode() {
|
||||
format!("https://{}", bp.registry.base_url().unwrap_or(server_name))
|
||||
if let Some(port) = bp.registry.http_port() {
|
||||
format!("https://{}:{}", server_name, port)
|
||||
} else {
|
||||
format!("https://{}", server_name)
|
||||
}
|
||||
} else {
|
||||
String::new()
|
||||
},
|
||||
url_http: if !bp.registry.is_bootstrap_mode() {
|
||||
format!("http://{}", bp.registry.base_url().unwrap_or(server_name))
|
||||
if let Some(port) = bp.registry.http_port() {
|
||||
format!("http://{}:{}", server_name, port)
|
||||
} else {
|
||||
format!("http://{}", server_name)
|
||||
}
|
||||
} else {
|
||||
String::new()
|
||||
},
|
||||
|
||||
@@ -276,8 +276,8 @@ impl RegistryStore {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn base_url(&self) -> Option<&str> {
|
||||
self.0.env_base_url.as_deref()
|
||||
pub fn http_port(&self) -> Option<u16> {
|
||||
self.0.env_http_port
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
@@ -323,7 +323,7 @@ impl RegistryStore {
|
||||
env_cluster_role: cluster_role,
|
||||
env_push_shard_id: push_shard_id,
|
||||
env_hostname: hostname,
|
||||
env_base_url: None,
|
||||
env_http_port: None,
|
||||
id_generator: utils::snowflake::SnowflakeIdGenerator::new(),
|
||||
})
|
||||
.await
|
||||
|
||||
@@ -217,7 +217,7 @@ pub struct RegistryStoreInner {
|
||||
pub(crate) env_cluster_role: Option<String>,
|
||||
pub(crate) env_push_shard_id: u32,
|
||||
pub(crate) env_hostname: String,
|
||||
pub(crate) env_base_url: Option<String>,
|
||||
pub(crate) env_http_port: Option<u16>,
|
||||
pub(crate) id_generator: SnowflakeIdGenerator,
|
||||
}
|
||||
|
||||
|
||||
@@ -52,9 +52,10 @@ impl RegistryStoreInner {
|
||||
"localhost".to_string()
|
||||
}
|
||||
}),
|
||||
env_base_url: std::env::var("STALWART_BASE_URL")
|
||||
env_http_port: std::env::var("STALWART_HTTP_PORT")
|
||||
.ok()
|
||||
.filter(|u| !u.is_empty()),
|
||||
.and_then(|v| v.trim().parse::<u16>().ok())
|
||||
.filter(|&u| u != 0),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user