diff options
author | metamuffin <metamuffin@disroot.org> | 2023-02-12 00:21:11 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-02-12 00:21:11 +0100 |
commit | 851ae4926fba296098fa5f08f99ba64622232ed2 (patch) | |
tree | b5d7809f8068fcb543b87d68aaf313d74612351a /src/main.rs | |
parent | 2eae89fe70950b4c7f1e088f98d35d1bd2202058 (diff) | |
download | gnix-851ae4926fba296098fa5f08f99ba64622232ed2.tar gnix-851ae4926fba296098fa5f08f99ba64622232ed2.tar.bz2 gnix-851ae4926fba296098fa5f08f99ba64622232ed2.tar.zst |
config path as arg
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 976cad5..f507ed5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ pub mod config; use crate::config::Config; -use anyhow::{bail, Context, Result}; +use anyhow::{anyhow, bail, Context, Result}; use http_body_util::{combinators::BoxBody, BodyExt}; use hyper::{ body::Incoming, @@ -24,7 +24,10 @@ use tokio_rustls::TlsAcceptor; async fn main() -> anyhow::Result<()> { env_logger::init_from_env("LOG"); - let config = Arc::new(Config::load()?); + let config_path = std::env::args().skip(1).next().ok_or(anyhow!( + "first argument is expected to be the configuration file" + ))?; + let config = Arc::new(Config::load(&config_path)?); tokio::select! { x = serve_http(config.clone()) => x.context("serving http")?, |