load config from json file

This commit is contained in:
Astro 2022-12-17 00:46:47 +01:00
parent 406df31b9b
commit aa9229adc6

View File

@ -71,11 +71,27 @@ async fn alerts(
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,