get_user_by_id

Function get_user_by_id 

Source
pub async fn get_user_by_id(
    __arg0: Path<i16>,
    __arg1: State<Arc<AppState>>,
) -> Result<impl IntoResponse, (StatusCode, Json<Value>)>
Expand description

Retrieves a single user’s details by their ID.

This endpoint allows fetching a specific User’s information. It returns a FilteredUser object (converted via filter_user), ensuring sensitive data like password hashes are not exposed.

§Arguments

  • Path(id): The ID of the User to retrieve, extracted from the URL path.
  • State(data): Application state containing AppState for database access.

§Returns

  • 200 OK with a FilteredUser JSON object if the user is found.
  • 404 Not Found if a user with the given ID does not exist.
  • 500 Internal Server Error if a database query error occurs.