extern crate actix_web; extern crate dotenvy; extern crate env_logger; extern crate ovunto_security; use std::env; use std::path::Path; use actix_web::middleware::Logger; use actix_web::{App, HttpServer}; use env_logger::Env; use ovunto_security::{Error, Result}; use crate::app::middlewares::Auth; use crate::app::state::AppState; mod app; #[actix_web::main] async fn main() -> Result<()> { dotenvy::from_path(Path::new("examples/server/.env")).expect("Couldn't read .env"); env_logger::init_from_env(Env::default().default_filter_or("debug")); let data = AppState::web(); HttpServer::new(move || { App::new() .app_data(data.clone()) .wrap(Auth::enabled()) .wrap(Logger::default()) .configure(app::config) }) .bind(env::var("SERVER_ADDR").expect("SERVER_ADDR should be set"))? .run() .await .map_err(Error::mapper) }