Skip to content

Commit

Permalink
Feat: Create "/me" route
Browse files Browse the repository at this point in the history
  • Loading branch information
rhwd committed Jun 3, 2024
1 parent f8da228 commit 36797ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/handlers/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,14 @@ pub async fn create(
}
}
}

pub async fn me(
State(app_state): State<Arc<AppState>>,
) -> Result<impl IntoResponse, impl IntoResponse>{
println!("{:?}", app_state.signed_jar);
if let Some(session_id) = app_state.signed_jar.get("session_id"){
Ok(session_id.to_string())
} else {
Err(StatusCode::UNAUTHORIZED)
}
}
3 changes: 2 additions & 1 deletion src/routes/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub fn create_routes(app_state: Arc<AppState>) -> Router {
Router::new()
.route("/users/:id", get(user::get_one))
.route("/users", post(user::create))
.route("/users/login", post(user::authorize))
.route("/users/login", post(user::authorize))
.route("/users/me", get(user::me))
.with_state(app_state)
}

0 comments on commit 36797ff

Please sign in to comment.