Documentation
¶
Index ¶
- Constants
- Variables
- func AuthMiddleware(log logrus.FieldLogger, loginRedirect http.HandlerFunc, ...) func(next http.Handler) http.Handler
- func DecodeError(w http.ResponseWriter, err error)
- func Error(w http.ResponseWriter, err error)
- func ErrorCode(w http.ResponseWriter, err error, code int)
- func MustJSON(w http.ResponseWriter, v interface{})
- type APIKey
- type APIKeyHandler
- type APIKeyService
- type AuthService
- type Errors
- type GeneratedAPIKey
- type User
- type UserHandler
- func (h UserHandler) ChangeAuthenticatedUserPassword(w http.ResponseWriter, r *http.Request)
- func (h UserHandler) ChangeUserPassword(w http.ResponseWriter, r *http.Request)
- func (h UserHandler) ChangeUserRole(w http.ResponseWriter, r *http.Request)
- func (h UserHandler) CreateUser(w http.ResponseWriter, r *http.Request)
- func (h UserHandler) DeleteUser(w http.ResponseWriter, r *http.Request)
- func (h UserHandler) DisableUser(w http.ResponseWriter, r *http.Request)
- func (h UserHandler) EnableUser(w http.ResponseWriter, r *http.Request)
- func (UserHandler) GetAuthenticatedUser(w http.ResponseWriter, r *http.Request)
- func (h UserHandler) GetUser(w http.ResponseWriter, r *http.Request)
- func (h UserHandler) ListUsers(w http.ResponseWriter, r *http.Request)
- func (h UserHandler) UpdateAuthenticatedUser(w http.ResponseWriter, r *http.Request)
- func (h UserHandler) UpdateUser(w http.ResponseWriter, r *http.Request)
- type UserService
Constants ¶
View Source
const JWTCookieName = "pyroscopeJWT"
Variables ¶
View Source
var ( ErrRequestBodyRequired = model.ValidationError{Err: errors.New("request body required")} ErrRequestBodyJSONInvalid = model.ValidationError{Err: errors.New("request body contains malformed JSON")} )
Functions ¶
func AuthMiddleware ¶
func AuthMiddleware(log logrus.FieldLogger, loginRedirect http.HandlerFunc, authService AuthService) func(next http.Handler) http.Handler
AuthMiddleware authenticates requests.
func DecodeError ¶
func DecodeError(w http.ResponseWriter, err error)
func Error ¶
func Error(w http.ResponseWriter, err error)
func ErrorCode ¶
func ErrorCode(w http.ResponseWriter, err error, code int)
ErrorCode replies to the request with the specified error message as JSON-encoded body.
If HTTP code is less than or equal zero, it will be deduced based on the error. If it fails, StatusInternalServerError will be returned without the response body. The error can be of 'multierror.Error' type.
It does not end the HTTP request; the caller should ensure no further writes are done to w.
func MustJSON ¶
func MustJSON(w http.ResponseWriter, v interface{})
Types ¶
type APIKey ¶
type APIKey struct {
ID uint `json:"id"`
Name string `json:"name"`
Role model.Role `json:"role"`
LastSeenAt *time.Time `json:"lastSeenAt,omitempty"`
ExpiresAt *time.Time `json:"expiresAt,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
APIKey represents a key fetched with a service query.
type APIKeyHandler ¶
type APIKeyHandler struct {
// contains filtered or unexported fields
}
func NewAPIKeyHandler ¶
func NewAPIKeyHandler(apiKeyService APIKeyService) APIKeyHandler
func (APIKeyHandler) CreateAPIKey ¶
func (h APIKeyHandler) CreateAPIKey(w http.ResponseWriter, r *http.Request)
func (APIKeyHandler) DeleteAPIKey ¶
func (h APIKeyHandler) DeleteAPIKey(w http.ResponseWriter, r *http.Request)
func (APIKeyHandler) ListAPIKeys ¶
func (h APIKeyHandler) ListAPIKeys(w http.ResponseWriter, r *http.Request)
type APIKeyService ¶
type AuthService ¶
type GeneratedAPIKey ¶
type GeneratedAPIKey struct {
ID uint `json:"id"`
Name string `json:"name"`
Role model.Role `json:"role"`
Key string `json:"key"`
ExpiresAt *time.Time `json:"expiresAt,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
GeneratedAPIKey represents newly generated API key with the JWT token.
type User ¶
type User struct {
ID uint `json:"id"`
Name string `json:"name"`
Email *string `json:"email,omitempty"`
FullName *string `json:"fullName,omitempty"`
Role model.Role `json:"role"`
IsDisabled bool `json:"isDisabled"`
IsExternal bool `json:"isExternal"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
LastSeenAt *time.Time `json:"lastSeenAt,omitempty"`
PasswordChangedAt time.Time `json:"passwordChangedAt"`
}
type UserHandler ¶
type UserHandler struct {
// contains filtered or unexported fields
}
func NewUserHandler ¶
func NewUserHandler(userService UserService) UserHandler
func (UserHandler) ChangeAuthenticatedUserPassword ¶
func (h UserHandler) ChangeAuthenticatedUserPassword(w http.ResponseWriter, r *http.Request)
func (UserHandler) ChangeUserPassword ¶
func (h UserHandler) ChangeUserPassword(w http.ResponseWriter, r *http.Request)
func (UserHandler) ChangeUserRole ¶
func (h UserHandler) ChangeUserRole(w http.ResponseWriter, r *http.Request)
func (UserHandler) CreateUser ¶
func (h UserHandler) CreateUser(w http.ResponseWriter, r *http.Request)
func (UserHandler) DeleteUser ¶
func (h UserHandler) DeleteUser(w http.ResponseWriter, r *http.Request)
func (UserHandler) DisableUser ¶
func (h UserHandler) DisableUser(w http.ResponseWriter, r *http.Request)
func (UserHandler) EnableUser ¶
func (h UserHandler) EnableUser(w http.ResponseWriter, r *http.Request)
func (UserHandler) GetAuthenticatedUser ¶
func (UserHandler) GetAuthenticatedUser(w http.ResponseWriter, r *http.Request)
func (UserHandler) GetUser ¶
func (h UserHandler) GetUser(w http.ResponseWriter, r *http.Request)
func (UserHandler) ListUsers ¶
func (h UserHandler) ListUsers(w http.ResponseWriter, r *http.Request)
func (UserHandler) UpdateAuthenticatedUser ¶
func (h UserHandler) UpdateAuthenticatedUser(w http.ResponseWriter, r *http.Request)
func (UserHandler) UpdateUser ¶
func (h UserHandler) UpdateUser(w http.ResponseWriter, r *http.Request)
type UserService ¶
type UserService interface {
CreateUser(context.Context, model.CreateUserParams) (model.User, error)
FindUserByID(context.Context, uint) (model.User, error)
GetAllUsers(context.Context) ([]model.User, error)
UpdateUserByID(context.Context, uint, model.UpdateUserParams) (model.User, error)
UpdateUserPasswordByID(context.Context, uint, model.UpdateUserPasswordParams) error
DeleteUserByID(context.Context, uint) error
}
Click to show internal directories.
Click to hide internal directories.