Merge remote-tracking branch 'origin/main' into main

main
Joey Hines 2021-05-31 18:54:55 -06:00
commit 3e44dc6932
No known key found for this signature in database
GPG Key ID: 80F567B5C968F91B
1 changed files with 29 additions and 6 deletions

View File

@ -1,12 +1,35 @@
use warp::Filter; 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] #[tokio::main]
async fn main() { async fn main() {
// GET /hello/warp => 200 OK with body "Hello, warp!" let args: Args = Args::from_args();
let hello = warp::path!("hello" / String)
.map(|name| format!("Hello, {}!", name));
warp::serve(hello) let cfg= GeoffreyAPIConfig::new(args.config.as_path()).unwrap();
.run(([127, 0, 0, 1], 3030))
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; .await;
} }