Fix issues with modifying the listen address

Signed-off-by: trivernis <trivernis@protonmail.com>
main
trivernis 3 years ago
parent 970210e420
commit 660ab98dd0
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

2
Cargo.lock generated

@ -606,7 +606,7 @@ dependencies = [
[[package]]
name = "multihook"
version = "0.1.0"
version = "0.1.1"
dependencies = [
"chrono",
"colored",

@ -4,7 +4,7 @@ description = "A webhook server"
authors = ["trivernis <trivernis@protonmail.com>"]
license = "GPL-3.0"
readme = "README.md"
version = "0.1.0"
version = "0.1.1"
edition = "2018"
repository = "https://github.com/Trivernis/multihook.git"

@ -28,7 +28,7 @@ multihook
The config allows you to configure actions for each endpoint. The config is most likely
stored in `~/.config/multihook` and on Windows maybe in the APPDATA directory (?).
After running the program for the first time there should be a `default-config.toml` file.
After running the program for the first time the config directory and config file should be created.
```toml
[server]

@ -36,5 +36,10 @@ async fn init_and_start() {
server.add_hook(endpoint.path.clone(), endpoint.into())
}
server.start(&settings.server.address).await
let address = settings
.server
.address
.clone()
.unwrap_or(String::from("127.0.0.1:8080"));
server.start(&address).await
}

@ -14,7 +14,7 @@ pub struct Settings {
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct ServerSettings {
pub address: String,
pub address: Option<String>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
@ -31,9 +31,7 @@ impl Default for Settings {
fn default() -> Self {
Self {
endpoints: HashMap::new(),
server: ServerSettings {
address: String::from("127.0.0.1:8080"),
},
server: ServerSettings { address: None },
}
}
}
@ -52,11 +50,11 @@ fn load_settings() -> MultihookResult<Settings> {
.unwrap_or(PathBuf::from(".config"));
if !Path::new(&config_dir).exists() {
fs::create_dir(&config_dir)?;
write_toml_pretty(
&config_dir.clone().join("config.toml"),
&Settings::default(),
)?;
}
write_toml_pretty(
&config_dir.clone().join("default-config.toml"),
&Settings::default(),
)?;
let mut settings = config::Config::default();
settings

Loading…
Cancel
Save