Function get_avatar

Source
pub async fn get_avatar(
    __arg0: State<AppState>,
    __arg1: Path<i64>,
) -> impl IntoResponse
Expand description

GET /api/auth/avatar/{user_id}

Returns the avatar image for a specific user ID.

§Authorization

This endpoint is public and does not require authentication.

§Response: 200 OK

  • Returns raw binary image data of the avatar
  • The Content-Type header is automatically inferred based on the file extension (e.g., image/png, image/jpeg)

§Example Request

GET /api/auth/avatar/42

§Example Response Headers

Content-Type: image/png

§Error Responses

§404 Not Found
  • User does not exist
  • No avatar is set
  • Avatar file is missing
{
  "success": false,
  "message": "No avatar set",
  "data": null
}
§500 Internal Server Error
  • Database error
  • File could not be opened or read
{
  "success": false,
  "message": "Failed to read avatar",
  "data": null
}