From 57bc8cd9c021feaf08e139e8fb62800bc476068e Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 3 Dec 2025 11:17:39 +0000 Subject: improved settings cli flags > env vars > defaults --- src/http/landing.rs | 8 ++++---- src/http/mod.rs | 4 ++-- src/http/nip11.rs | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/http') diff --git a/src/http/landing.rs b/src/http/landing.rs index b978851..f9fca5b 100644 --- a/src/http/landing.rs +++ b/src/http/landing.rs @@ -282,7 +282,7 @@ pub fn get_html(config: &Config) -> String { format!( include_str!("../../templates/landing.html"), base_css = get_base_css(), - relay_name = config.relay_name, + relay_name = config.relay_name(), relay_description = config.relay_description, version = get_version(), curation = curation, @@ -357,7 +357,7 @@ pub fn get_generic_404_html(config: &Config, path: &str) -> String { "##, base_css = get_base_css(), - relay_name = config.relay_name, + relay_name = config.relay_name(), path = path, version = get_version(), footer_script = get_footer_script(), @@ -456,7 +456,7 @@ pub fn get_404_html(config: &Config, npub: &str, identifier: &str) -> String { "##, base_css = get_base_css(), - relay_name = config.relay_name, + relay_name = config.relay_name(), npub = npub, identifier = identifier, version = get_version(), @@ -598,7 +598,7 @@ pub fn get_repo_html(config: &Config, npub: &str, identifier: &str) -> String { "##, base_css = get_base_css(), - relay_name = config.relay_name, + relay_name = config.relay_name(), npub = npub, identifier = identifier, version = get_version(), diff --git a/src/http/mod.rs b/src/http/mod.rs index 4665281..8b1f687 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -118,7 +118,7 @@ impl Service> for HttpService { let path = req.uri().path().to_string(); let query = req.uri().query().map(|s| s.to_string()); let method = req.method().clone(); - let git_data_path = self.config.git_data_path.clone(); + let git_data_path = self.config.effective_git_data_path(); let database = self.database.clone(); // Handle OPTIONS preflight requests (CORS) @@ -427,7 +427,7 @@ pub async fn run_server( let bind_addr: SocketAddr = config.bind_address.parse()?; tracing::info!("Starting HTTP server on {}", bind_addr); - tracing::info!("Relay name: {}", config.relay_name); + tracing::info!("Relay name: {}", config.relay_name()); tracing::info!("Domain: {}", config.domain); let listener = TcpListener::bind(&bind_addr).await?; diff --git a/src/http/nip11.rs b/src/http/nip11.rs index ecb9769..e6a1e46 100644 --- a/src/http/nip11.rs +++ b/src/http/nip11.rs @@ -57,9 +57,9 @@ impl RelayInformationDocument { /// Create NIP-11 relay information document from configuration pub fn from_config(config: &Config) -> Self { Self { - name: config.relay_name.clone(), + name: config.relay_name(), description: config.relay_description.clone(), - pubkey: Some(config.owner_npub.clone()), + pubkey: config.owner_npub.clone(), contact: None, // Could be added to config if needed supported_nips: vec![ 1, // NIP-01: Basic protocol flow @@ -98,8 +98,8 @@ mod tests { fn test_relay_information_document_structure() { let config = Config { domain: "relay.example.com".to_string(), - owner_npub: "npub1test".to_string(), - relay_name: "Test Relay".to_string(), + owner_npub: Some("npub1test".to_string()), + relay_name_override: Some("Test Relay".to_string()), relay_description: "A test relay".to_string(), git_data_path: "./data/git".to_string(), relay_data_path: "./data/relay".to_string(), @@ -128,8 +128,8 @@ mod tests { fn test_relay_information_document_json() { let config = Config { domain: "relay.example.com".to_string(), - owner_npub: "npub1test".to_string(), - relay_name: "Test Relay".to_string(), + owner_npub: Some("npub1test".to_string()), + relay_name_override: Some("Test Relay".to_string()), relay_description: "A test relay".to_string(), git_data_path: "./data/git".to_string(), relay_data_path: "./data/relay".to_string(), -- cgit v1.2.3