VirtWeb/virtweb_backend/src/main.rs

25 lines
792 B
Rust
Raw Normal View History

2023-09-02 06:07:06 +00:00
use actix_remote_ip::RemoteIPConfig;
use actix_web::{App, HttpServer, web};
use virtweb_backend::app_config::AppConfig;
use actix_web::middleware::Logger;
use virtweb_backend::controllers::server_controller;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
log::info!("Start to listen on {}", AppConfig::get().listen_address);
HttpServer::new(|| {
App::new()
.wrap(Logger::default())
.app_data(web::Data::new(RemoteIPConfig {
proxy: AppConfig::get().proxy_ip.clone()
}))
.route("/", web::get().to(server_controller::root_index))
})
.bind(&AppConfig::get().listen_address)?
.run()
.await
2023-09-01 08:59:53 +00:00
}