32 lines
944 B
Rust
32 lines
944 B
Rust
#[cfg(not(target_env = "msvc"))]
|
|
use tikv_jemallocator::Jemalloc;
|
|
|
|
#[cfg(not(target_env = "msvc"))]
|
|
#[global_allocator]
|
|
static GLOBAL: Jemalloc = Jemalloc;
|
|
|
|
use actix_cors::Cors;
|
|
use actix_web::{http::header, middleware, App, HttpServer};
|
|
|
|
#[actix_web::main]
|
|
async fn main() -> std::io::Result<()> {
|
|
std::env::set_var("RUST_LOG", "info");
|
|
env_logger::init();
|
|
|
|
let server = HttpServer::new(move || {
|
|
App::new()
|
|
.wrap(
|
|
Cors::default()
|
|
.allow_any_origin()
|
|
.allowed_methods(vec!["POST", "GET"])
|
|
.allowed_header(header::ACCEPT)
|
|
.allowed_header(header::CONTENT_TYPE)
|
|
.supports_credentials()
|
|
.max_age(3600),
|
|
)
|
|
.wrap(middleware::Compress::default())
|
|
.wrap(middleware::Logger::default())
|
|
});
|
|
server.bind("0.0.0.0:80").unwrap().run().await
|
|
}
|