diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-03 11:17:39 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-03 11:19:20 +0000 |
| commit | 57bc8cd9c021feaf08e139e8fb62800bc476068e (patch) | |
| tree | c62abdffb4c91999cae2f570597b9ac154c2e51d /src/http | |
| parent | 2f8ecd482077d82f2d1a937c7f979eaaa87a27b2 (diff) | |
improved settings cli flags > env vars > defaults
Diffstat (limited to 'src/http')
| -rw-r--r-- | src/http/landing.rs | 8 | ||||
| -rw-r--r-- | src/http/mod.rs | 4 | ||||
| -rw-r--r-- | src/http/nip11.rs | 12 |
3 files changed, 12 insertions, 12 deletions
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 { | |||
| 282 | format!( | 282 | format!( |
| 283 | include_str!("../../templates/landing.html"), | 283 | include_str!("../../templates/landing.html"), |
| 284 | base_css = get_base_css(), | 284 | base_css = get_base_css(), |
| 285 | relay_name = config.relay_name, | 285 | relay_name = config.relay_name(), |
| 286 | relay_description = config.relay_description, | 286 | relay_description = config.relay_description, |
| 287 | version = get_version(), | 287 | version = get_version(), |
| 288 | curation = curation, | 288 | curation = curation, |
| @@ -357,7 +357,7 @@ pub fn get_generic_404_html(config: &Config, path: &str) -> String { | |||
| 357 | </body> | 357 | </body> |
| 358 | </html>"##, | 358 | </html>"##, |
| 359 | base_css = get_base_css(), | 359 | base_css = get_base_css(), |
| 360 | relay_name = config.relay_name, | 360 | relay_name = config.relay_name(), |
| 361 | path = path, | 361 | path = path, |
| 362 | version = get_version(), | 362 | version = get_version(), |
| 363 | footer_script = get_footer_script(), | 363 | footer_script = get_footer_script(), |
| @@ -456,7 +456,7 @@ pub fn get_404_html(config: &Config, npub: &str, identifier: &str) -> String { | |||
| 456 | </body> | 456 | </body> |
| 457 | </html>"##, | 457 | </html>"##, |
| 458 | base_css = get_base_css(), | 458 | base_css = get_base_css(), |
| 459 | relay_name = config.relay_name, | 459 | relay_name = config.relay_name(), |
| 460 | npub = npub, | 460 | npub = npub, |
| 461 | identifier = identifier, | 461 | identifier = identifier, |
| 462 | version = get_version(), | 462 | version = get_version(), |
| @@ -598,7 +598,7 @@ pub fn get_repo_html(config: &Config, npub: &str, identifier: &str) -> String { | |||
| 598 | </body> | 598 | </body> |
| 599 | </html>"##, | 599 | </html>"##, |
| 600 | base_css = get_base_css(), | 600 | base_css = get_base_css(), |
| 601 | relay_name = config.relay_name, | 601 | relay_name = config.relay_name(), |
| 602 | npub = npub, | 602 | npub = npub, |
| 603 | identifier = identifier, | 603 | identifier = identifier, |
| 604 | version = get_version(), | 604 | 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<Request<Incoming>> for HttpService { | |||
| 118 | let path = req.uri().path().to_string(); | 118 | let path = req.uri().path().to_string(); |
| 119 | let query = req.uri().query().map(|s| s.to_string()); | 119 | let query = req.uri().query().map(|s| s.to_string()); |
| 120 | let method = req.method().clone(); | 120 | let method = req.method().clone(); |
| 121 | let git_data_path = self.config.git_data_path.clone(); | 121 | let git_data_path = self.config.effective_git_data_path(); |
| 122 | let database = self.database.clone(); | 122 | let database = self.database.clone(); |
| 123 | 123 | ||
| 124 | // Handle OPTIONS preflight requests (CORS) | 124 | // Handle OPTIONS preflight requests (CORS) |
| @@ -427,7 +427,7 @@ pub async fn run_server( | |||
| 427 | let bind_addr: SocketAddr = config.bind_address.parse()?; | 427 | let bind_addr: SocketAddr = config.bind_address.parse()?; |
| 428 | 428 | ||
| 429 | tracing::info!("Starting HTTP server on {}", bind_addr); | 429 | tracing::info!("Starting HTTP server on {}", bind_addr); |
| 430 | tracing::info!("Relay name: {}", config.relay_name); | 430 | tracing::info!("Relay name: {}", config.relay_name()); |
| 431 | tracing::info!("Domain: {}", config.domain); | 431 | tracing::info!("Domain: {}", config.domain); |
| 432 | 432 | ||
| 433 | let listener = TcpListener::bind(&bind_addr).await?; | 433 | 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 { | |||
| 57 | /// Create NIP-11 relay information document from configuration | 57 | /// Create NIP-11 relay information document from configuration |
| 58 | pub fn from_config(config: &Config) -> Self { | 58 | pub fn from_config(config: &Config) -> Self { |
| 59 | Self { | 59 | Self { |
| 60 | name: config.relay_name.clone(), | 60 | name: config.relay_name(), |
| 61 | description: config.relay_description.clone(), | 61 | description: config.relay_description.clone(), |
| 62 | pubkey: Some(config.owner_npub.clone()), | 62 | pubkey: config.owner_npub.clone(), |
| 63 | contact: None, // Could be added to config if needed | 63 | contact: None, // Could be added to config if needed |
| 64 | supported_nips: vec![ | 64 | supported_nips: vec![ |
| 65 | 1, // NIP-01: Basic protocol flow | 65 | 1, // NIP-01: Basic protocol flow |
| @@ -98,8 +98,8 @@ mod tests { | |||
| 98 | fn test_relay_information_document_structure() { | 98 | fn test_relay_information_document_structure() { |
| 99 | let config = Config { | 99 | let config = Config { |
| 100 | domain: "relay.example.com".to_string(), | 100 | domain: "relay.example.com".to_string(), |
| 101 | owner_npub: "npub1test".to_string(), | 101 | owner_npub: Some("npub1test".to_string()), |
| 102 | relay_name: "Test Relay".to_string(), | 102 | relay_name_override: Some("Test Relay".to_string()), |
| 103 | relay_description: "A test relay".to_string(), | 103 | relay_description: "A test relay".to_string(), |
| 104 | git_data_path: "./data/git".to_string(), | 104 | git_data_path: "./data/git".to_string(), |
| 105 | relay_data_path: "./data/relay".to_string(), | 105 | relay_data_path: "./data/relay".to_string(), |
| @@ -128,8 +128,8 @@ mod tests { | |||
| 128 | fn test_relay_information_document_json() { | 128 | fn test_relay_information_document_json() { |
| 129 | let config = Config { | 129 | let config = Config { |
| 130 | domain: "relay.example.com".to_string(), | 130 | domain: "relay.example.com".to_string(), |
| 131 | owner_npub: "npub1test".to_string(), | 131 | owner_npub: Some("npub1test".to_string()), |
| 132 | relay_name: "Test Relay".to_string(), | 132 | relay_name_override: Some("Test Relay".to_string()), |
| 133 | relay_description: "A test relay".to_string(), | 133 | relay_description: "A test relay".to_string(), |
| 134 | git_data_path: "./data/git".to_string(), | 134 | git_data_path: "./data/git".to_string(), |
| 135 | relay_data_path: "./data/relay".to_string(), | 135 | relay_data_path: "./data/relay".to_string(), |