Add base server
This commit is contained in:
@ -1,3 +1,24 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
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
|
||||
}
|
||||
|
Reference in New Issue
Block a user