use actix_web::{ client::Client, middleware::{Compress, Logger}, App, HttpServer, }; use structopt::StructOpt; #[actix_web::main] async fn main() -> Result<(), anyhow::Error> { if std::env::var("RUST_LOG").is_err() { std::env::set_var("RUST_LOG", "info,pict_rs_aggregator=info,actix_web=info"); } env_logger::init(); let db = sled::open("sled/db-0-34")?; let config = pict_rs_aggregator::Config::from_args(); let bind_address = config.bind_address(); let state = pict_rs_aggregator::state(config, "", db)?; HttpServer::new(move || { let client = Client::builder() .header("User-Agent", "pict_rs_aggregator-v0.1.0") .finish(); App::new() .wrap(Logger::default()) .wrap(Compress::default()) .service(pict_rs_aggregator::service(client, state.clone())) }) .bind(bind_address)? .run() .await?; Ok(()) }