load config from json file

This commit is contained in:
Astro 2022-12-17 00:46:47 +01:00
parent 406df31b9b
commit aa9229adc6
1 changed files with 17 additions and 1 deletions

View File

@ -67,15 +67,31 @@ async fn alerts(
jabber.send_message(message).await;
});
}
StatusCode::OK.into_response()
}
#[derive(Deserialize)]
struct Config {
listen_port: u16,
jid: String,
password: String,
muc: String,
}
#[tokio::main]
async fn main() {
// initialize tracing
tracing_subscriber::fmt::init();
let config: Config = serde_json::from_str(
&std::fs::read_to_string(
std::env::args()
.skip(1)
.next()
.expect("Call with config.json")
).expect("read config")
).expect("parse config");
let jabber = jabber::run(/*secret*/).await;
let state = AppState {
jabber,