feat: add model
This commit is contained in:
parent
c5f6a24b3a
commit
42a75ba800
6 changed files with 117 additions and 1 deletions
|
|
@ -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("./")))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue