mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-23 09:29:06 -05:00
feat: add custom relay page
This commit is contained in:
parent
05411eb9e3
commit
6329acd82b
|
@ -141,6 +141,7 @@ be mounted into a docker container like so:
|
||||||
$ docker run -it -p 7000:8080 \
|
$ docker run -it -p 7000:8080 \
|
||||||
--mount src=$(pwd)/config.toml,target=/usr/src/app/config.toml,type=bind \
|
--mount src=$(pwd)/config.toml,target=/usr/src/app/config.toml,type=bind \
|
||||||
--mount src=$(pwd)/data,target=/usr/src/app/db,type=bind \
|
--mount src=$(pwd)/data,target=/usr/src/app/db,type=bind \
|
||||||
|
--mount src=$(pwd)/index.html,target=/usr/src/app/index.html,type=bind \
|
||||||
nostr-rs-relay
|
nostr-rs-relay
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ description = "A newly created nostr-rs-relay.\n\nCustomize this with your own i
|
||||||
# URL of Relay's icon.
|
# URL of Relay's icon.
|
||||||
#relay_icon = "https://example.test/img.png"
|
#relay_icon = "https://example.test/img.png"
|
||||||
|
|
||||||
|
# Path to custom relay html page
|
||||||
|
#relay_page = "index.html"
|
||||||
|
|
||||||
[diagnostics]
|
[diagnostics]
|
||||||
# Enable tokio tracing (for use with tokio-console)
|
# Enable tokio tracing (for use with tokio-console)
|
||||||
#tracing = false
|
#tracing = false
|
||||||
|
|
|
@ -14,6 +14,7 @@ pub struct Info {
|
||||||
pub contact: Option<String>,
|
pub contact: Option<String>,
|
||||||
pub favicon: Option<String>,
|
pub favicon: Option<String>,
|
||||||
pub relay_icon: Option<String>,
|
pub relay_icon: Option<String>,
|
||||||
|
pub relay_page: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
@ -285,6 +286,7 @@ impl Default for Settings {
|
||||||
contact: None,
|
contact: None,
|
||||||
favicon: None,
|
favicon: None,
|
||||||
relay_icon: None,
|
relay_icon: None,
|
||||||
|
relay_page: None,
|
||||||
},
|
},
|
||||||
diagnostics: Diagnostics { tracing: false },
|
diagnostics: Diagnostics { tracing: false },
|
||||||
database: Database {
|
database: Database {
|
||||||
|
|
|
@ -194,6 +194,21 @@ async fn handle_web_request(
|
||||||
.unwrap());
|
.unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(relay_file_path) = settings.info.relay_page {
|
||||||
|
match file_bytes(&relay_file_path) {
|
||||||
|
Ok(file_content) => {
|
||||||
|
return Ok(Response::builder()
|
||||||
|
.status(200)
|
||||||
|
.header("Content-Type", "text/html; charset=UTF-8")
|
||||||
|
.body(Body::from(file_content))
|
||||||
|
.expect("request builder"));
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
error!("Failed to read relay_page file: {}. Will use default", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(Response::builder()
|
Ok(Response::builder()
|
||||||
.status(200)
|
.status(200)
|
||||||
.header("Content-Type", "text/plain")
|
.header("Content-Type", "text/plain")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user