27 lines
615 B
Rust
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
|
|
}
|