14 lines
387 B
Rust
14 lines
387 B
Rust
use axum::http::StatusCode;
|
|
use axum::response::IntoResponse;
|
|
use axum::Extension;
|
|
use serde_json::json;
|
|
|
|
use crate::auth::OptionalUser;
|
|
|
|
pub async fn get_me(Extension(user): Extension<OptionalUser>) -> impl IntoResponse {
|
|
let body = match user.0 {
|
|
Some(usr) => json!({ "user": usr }),
|
|
None => json!({ "user": null }),
|
|
};
|
|
(StatusCode::OK, axum::Json(body))
|
|
}
|