generated from adrienaury/go-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Description
This endpoint allows a user to retrieve their own user information.
Request
Method
GET
URL
/users/me
Request Parameters
| Parameter | Description | Required | Example |
|---|---|---|---|
| timeout | The amount of time, in seconds, to wait for the request to complete. | No | 30 |
Result
Result parameters
| Parameter | Description | Type |
|---|---|---|
| id | The unique identifier for the user. | UUID |
| organization_id | The unique identifier for the organization the user belongs to. | UUID |
| username | The username of the user. | string |
| The email address of the user. | string | |
| role | The role of the user. | UserRole |
| max_allowed_dimensions_per_dataset | The maximum number of dimensions allowed per dataset for the user. | int |
| max_allowed_lines_per_dataset | The maximum number of lines allowed per dataset for the user. | int |
Result Body
The result body is a JSON object with the following structure:
{
"id": "d810b289-53a3-48d9-a5e0-a16a64185635",
"organization_id": "30e13e75-574c-42c1-8c13-c374c372c320",
"username": "john.smith",
"email": "john.smith@example.com",
"role": "user",
"max_allowed_dimensions_per_dataset": 1000,
"max_allowed_lines_per_dataset": 1000000
}Example Curl Request
Request
curl -X GET http://localhost:8080/users/me
Curl Response
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "d810b289-53a3-48d9-a5e0-a16a64185635",
"organization_id": "30e13e75-574c-42c1-8c13-c374c372c320",
"username": "john.smith",
"email": "john.smith@example.com",
"role": "user",
"max_allowed_dimensions_per_dataset": 1000,
"max_allowed_lines_per_dataset": 1000000
}
Go server
Struct
type User struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
Username string `json:"username"`
Email string `json:"email"`
Role UserRole `json:"role"`
MaxAllowedDimensionsPerDataset int `json:"max_allowed_dimensions_per_dataset"`
MaxAllowedLinesPerDataset int `json:"max_allowed_lines_per_dataset"`
}Handler
func (s *server) handleGetMe(ctx context.Context, w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(ctx, s.timeout)
defer cancel()
user, err := s.service.GetMe(ctx)
if err != nil {
log.Printf("failed to get user: %v", err)
http.Error(w, http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
return
}
if err := json.NewEncoder(w).Encode(user); err != nil {
log.Printf("failed to encode user: %v", err)
http.Error(w, http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
return
}
}
``` to the response.
w.Write(json)
}Links
Automated Issue Details
Dear visitor,
This issue has been automatically generated from the Octopize project avatar-python to make SIGO compatible. Please vote with a thumbs up or thumbs down to assess the quality of the automatic generation.
Best regards,
The SIGO Team
Reactions are currently unavailable