initial commit (backend) (pending TODOs, will amend)
This commit is contained in:
61
src/main.rs
Normal file
61
src/main.rs
Normal file
@@ -0,0 +1,61 @@
|
||||
use clap::Parser as _;
|
||||
|
||||
mod args;
|
||||
mod config;
|
||||
mod server;
|
||||
|
||||
mod consts {
|
||||
pub static TEMPLATE_CFG: &str = include_str!("../data/example-config.toml");
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let args = args::Args::parse();
|
||||
|
||||
match args.command {
|
||||
args::Command::Serve {
|
||||
config_path,
|
||||
listen,
|
||||
} => {
|
||||
use server::{ServeArgs, run_server};
|
||||
|
||||
let config = config::Config::open(config_path)?;
|
||||
|
||||
println!("{config:#?}");
|
||||
|
||||
let rt = tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()?;
|
||||
|
||||
rt.block_on(async { run_server(ServeArgs { listen }, config).await })?;
|
||||
}
|
||||
args::Command::Features => {
|
||||
let http2 = cfg!(feature = "http2");
|
||||
let compress = cfg!(feature = "compress");
|
||||
|
||||
let http2_req = cfg!(feature = "http2-req");
|
||||
let compress_req = cfg!(feature = "compress-req");
|
||||
|
||||
let native_tls = cfg!(feature = "native-tls");
|
||||
let rustls = cfg!(feature = "rustls");
|
||||
|
||||
println!(
|
||||
"Server Features:\
|
||||
\n http2 enabled: {http2}\
|
||||
\n compress enabled: {compress}\
|
||||
\n\
|
||||
\nRequest Features:\
|
||||
\n http2-req enabled: {http2_req}\
|
||||
\n compress-req enabled: {compress_req}\
|
||||
\n\
|
||||
\n TLS Features:\
|
||||
\n native-tls enabled = {native_tls}\
|
||||
\n rustls enabled = {rustls}"
|
||||
);
|
||||
}
|
||||
args::Command::TemplateConfig => {
|
||||
println!("{}", consts::TEMPLATE_CFG);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user