feat: add configuration through file

A file named `config.toml` can now be used to load the address, port,
and some websocket configuration settings.

Fixes https://todo.sr.ht/~gheartsfield/nostr-rs-relay/3
This commit is contained in:
Greg Heartsfield
2021-12-29 22:13:02 -06:00
parent 2e2e01203b
commit d730bf0c59
6 changed files with 249 additions and 19 deletions
+9
View File
@@ -34,6 +34,8 @@ pub enum Error {
CommandUnknownError,
#[error("SQL error")]
SqlError(rusqlite::Error),
#[error("Config error")]
ConfigError(config::ConfigError),
}
impl From<rusqlite::Error> for Error {
@@ -56,3 +58,10 @@ impl From<WsError> for Error {
Error::WebsocketError(r)
}
}
impl From<config::ConfigError> for Error {
/// Wrap Config error
fn from(r: config::ConfigError) -> Self {
Error::ConfigError(r)
}
}