This repository has been archived on 2024-08-23. You can view files and clone it, but cannot push or open issues or pull requests.
Files
project/src/endpoints/users/get.rs

27 lines
615 B
Rust

use crate::prelude::*;
#[derive(Deserialize, Debug)]
pub struct Params {
user_id: i32,
}
type Response = GeneralResult<Json<db::users::UserInfo>>;
pub async fn get(State(pool): State<Pool>, Query(params): Query<Params>) -> Response {
db::users::get(params.user_id, &pool)
.await
.handle_internal("Error getting the user")?
.handle(StatusCode::NOT_FOUND, "User not found")
.map(Json)
}
pub async fn current(state: State<Pool>, claims: Claims) -> Response {
get(
state,
Query(Params {
user_id: claims.user_id,
}),
)
.await
}