diff options
author | Toby Vincent <tobyv@tobyvin.dev> | 2024-04-06 02:09:26 -0500 |
---|---|---|
committer | Toby Vincent <tobyv@tobyvin.dev> | 2024-04-06 02:10:32 -0500 |
commit | 9822bc18bb0cb5e13104376ecefc6ec99d93b016 (patch) | |
tree | 0137399c270a69a2c09e7c0e4c41f64cad5dbbfe /src/routes.rs | |
parent | f7dd456941dbc5f926a04935d3aaaa198741608e (diff) |
feat: impl jwt auth middleware and user route
Diffstat (limited to 'src/routes.rs')
-rw-r--r-- | src/routes.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/routes.rs b/src/routes.rs index e2f5587..165dfb6 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -2,11 +2,12 @@ use std::sync::Arc; use axum::{ http::{StatusCode, Uri}, + middleware::map_request_with_state, response::IntoResponse, }; use axum_extra::routing::RouterExt; -use crate::state::AppState; +use crate::{jwt::authenticate, state::AppState}; mod healthcheck; mod login; @@ -16,12 +17,13 @@ mod user; #[tracing::instrument] pub fn init_router(state: Arc<AppState>) -> axum::Router { axum::Router::new() - // .route("/api/user", get(get_user)) + .typed_get(user::User::get) + .typed_get(login::Logout::get) + .route_layer(map_request_with_state(state.clone(), authenticate)) .typed_get(healthcheck::HealthCheck::get) .typed_get(user::UserUuid::get) .typed_post(register::Register::post) .typed_post(login::Login::post) - .typed_get(login::Logout::get) .fallback(fallback) .with_state(state) } |