mod commands; mod error; mod context; mod config; mod responses; use structopt::StructOpt; use std::path::PathBuf; use crate::config::GeoffreyAPIConfig; use std::net::SocketAddr; use std::str::FromStr; use crate::context::Context; use crate::commands::command_filter; #[derive(Debug, StructOpt, Clone)] #[structopt(name = "GeoffreyAPI", about = "Geoffrey Central API")] struct Args { #[structopt(env = "GEOFFREY_CONFIG", parse(from_os_str))] config: PathBuf, } #[tokio::main] async fn main() { let args: Args = Args::from_args(); let cfg= GeoffreyAPIConfig::new(args.config.as_path()).unwrap(); let ctx = Context::new(cfg).unwrap(); let api = command_filter(ctx.clone()); warp::serve(api) .run(SocketAddr::from_str(ctx.cfg.host.as_str()).unwrap()) .await; }