use actix_web::{web, App, HttpRequest, HttpServer, Responder}; mod config; mod proxy; use proxy::Mirror; async fn index(req: HttpRequest) -> impl Responder { let path = req.path(); let p: &actix_web::web::Data = req.app_data().unwrap(); let data = p.get(path, &req).await; data.unwrap() } #[actix_web::main] async fn main() -> std::io::Result<()> { env_logger::init(); let proxym = { let config: config::Config = toml::from_str(&std::fs::read_to_string("./mirrord.conf").unwrap()).unwrap(); config.to_proxy() }; let proxym = actix_web::web::Data::new(proxym); HttpServer::new(move || { App::new() .wrap(actix_web::middleware::Logger::default()) .app_data(proxym.clone()) .service(web::resource("/{path:.*}").to(index)) }) .bind("0.0.0.0:8080")? .run() .await }