feat: add auth things

This commit is contained in:
Sandro Eiler 2023-10-07 22:14:22 +02:00
parent 42a75ba800
commit 88c4045d33
7 changed files with 182 additions and 20 deletions

View file

@ -1,5 +1,7 @@
#![allow(unused)]
use crate::model::ModelController;
pub use self::error::{Error, Result};
use std::net::SocketAddr;
@ -25,10 +27,15 @@ struct HelloParams {
}
#[tokio::main]
async fn main() {
async fn main() -> Result<()>{
let mc = ModelController::new().await?;
let routes_apis = web::routes_properties::routes(mc.clone()).route_layer(middleware::from_fn(web::mw_auth::mw_require_auth));
let routes_all = Router::new()
.merge(routes_hello())
.merge(web::routes_login::routes())
.nest("/api", routes_apis)
.layer(middleware::map_response(main_response_mapper))
.layer(CookieManagerLayer::new()) // must be above? the auth routes
// TODO: continue video at 22:15
@ -40,6 +47,8 @@ async fn main() {
.serve(routes_all.into_make_service())
.await
.unwrap();
Ok(())
}