47 lines
1 KiB
Rust
47 lines
1 KiB
Rust
|
#[cfg(not(target_env = "msvc"))]
|
||
|
use tikv_jemallocator::Jemalloc;
|
||
|
|
||
|
#[cfg(not(target_env = "msvc"))]
|
||
|
#[global_allocator]
|
||
|
static GLOBAL: Jemalloc = Jemalloc;
|
||
|
|
||
|
use actix_web::{
|
||
|
http::header,
|
||
|
middleware,
|
||
|
web::{self, Data},
|
||
|
App, Error, HttpResponse, HttpServer,
|
||
|
};
|
||
|
use clap::{Parser, Subcommand};
|
||
|
|
||
|
use backend::*;
|
||
|
|
||
|
#[derive(Debug, Parser)]
|
||
|
#[clap(author, version, about, long_about = None)]
|
||
|
struct Cli {
|
||
|
#[clap(subcommand)]
|
||
|
commands: Commands,
|
||
|
}
|
||
|
|
||
|
#[derive(Debug, Subcommand)]
|
||
|
enum Commands {
|
||
|
#[clap(about = "Starts webserver")]
|
||
|
Run,
|
||
|
}
|
||
|
|
||
|
#[actix_web::main]
|
||
|
async fn main() -> std::io::Result<()> {
|
||
|
match Cli::parse().commands {
|
||
|
Commands::Run => {
|
||
|
std::env::set_var("RUST_LOG", "info");
|
||
|
env_logger::init();
|
||
|
|
||
|
let server = HttpServer::new(move || {
|
||
|
App::new()
|
||
|
.wrap(middleware::Compress::default())
|
||
|
.wrap(middleware::Logger::default())
|
||
|
});
|
||
|
server.bind("0.0.0.0:80").unwrap().run().await
|
||
|
}
|
||
|
}
|
||
|
}
|