mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 14:29:40 +02:00
* refactor(api): refactor base import path * fix(build-system): update build_binary_devops * fix(build-system): fix build_binary_devops for linux * fix(build-system): fix build_binary_devops for Windows
28 lines
997 B
Go
28 lines
997 B
Go
package users
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
httperror "github.com/portainer/libhttp/error"
|
|
"github.com/portainer/libhttp/request"
|
|
"github.com/portainer/libhttp/response"
|
|
"github.com/portainer/portainer/api"
|
|
)
|
|
|
|
// GET request on /api/users/:id
|
|
func (handler *Handler) userInspect(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
|
userID, err := request.RetrieveNumericRouteVariableValue(r, "id")
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusBadRequest, "Invalid user identifier route variable", err}
|
|
}
|
|
|
|
user, err := handler.UserService.User(portainer.UserID(userID))
|
|
if err == portainer.ErrObjectNotFound {
|
|
return &httperror.HandlerError{http.StatusNotFound, "Unable to find a user with the specified identifier inside the database", err}
|
|
} else if err != nil {
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to find a user with the specified identifier inside the database", err}
|
|
}
|
|
|
|
hideFields(user)
|
|
return response.JSON(w, user)
|
|
}
|