feat: add model

This commit is contained in:
Sandro Eiler 2023-10-05 14:33:12 +02:00
parent c5f6a24b3a
commit 42a75ba800
6 changed files with 117 additions and 1 deletions

View file

@ -17,6 +17,7 @@ use tower_cookies::CookieManagerLayer;
mod error;
mod web;
mod model;
#[derive(Debug, Deserialize)]
struct HelloParams {
@ -29,7 +30,8 @@ async fn main() {
.merge(routes_hello())
.merge(web::routes_login::routes())
.layer(middleware::map_response(main_response_mapper))
.layer(CookieManagerLayer::new())
.layer(CookieManagerLayer::new()) // must be above? the auth routes
// TODO: continue video at 22:15
.fallback_service(routes_static());
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
@ -40,6 +42,10 @@ async fn main() {
.unwrap();
}
/// Map the response to add headers, etc.
///
/// * `res`: the response to map
async fn main_response_mapper(res: Response) -> Response {
println!("->> {:<12} - main_response_mapper", "HANDLER");
@ -47,6 +53,7 @@ async fn main_response_mapper(res: Response) -> Response {
res
}
/// Serve static files
fn routes_static() -> Router {
Router::new().nest_service("/", get_service(ServeDir::new("./")))
}