mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-23 01: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 \
|
||||
--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)/index.html,target=/usr/src/app/index.html,type=bind \
|
||||
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.
|
||||
#relay_icon = "https://example.test/img.png"
|
||||
|
||||
# Path to custom relay html page
|
||||
#relay_page = "index.html"
|
||||
|
||||
[diagnostics]
|
||||
# Enable tokio tracing (for use with tokio-console)
|
||||
#tracing = false
|
||||
|
|
|
@ -14,6 +14,7 @@ pub struct Info {
|
|||
pub contact: Option<String>,
|
||||
pub favicon: Option<String>,
|
||||
pub relay_icon: Option<String>,
|
||||
pub relay_page: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
@ -285,6 +286,7 @@ impl Default for Settings {
|
|||
contact: None,
|
||||
favicon: None,
|
||||
relay_icon: None,
|
||||
relay_page: None,
|
||||
},
|
||||
diagnostics: Diagnostics { tracing: false },
|
||||
database: Database {
|
||||
|
|
|
@ -194,6 +194,21 @@ async fn handle_web_request(
|
|||
.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()
|
||||
.status(200)
|
||||
.header("Content-Type", "text/plain")
|
||||
|
|
Loading…
Reference in New Issue
Block a user