Documentation ¶
Index ¶
Constants ¶
const ( UsersFirstNameMinLength = 2 UsersFirstNameMaxLength = 255 UsersLastNameMinLength = 2 UsersLastNameMaxLength = 255 UsersEmailMinLength = 6 UsersEmailMaxLength = 255 UsersPasswordMinLength = 6 UsersPasswordMaxLength = 255 )
Variables ¶
var ( ErrInternalServerError = errors.New("internal server error") ErrBadRequest = errors.New("bad request") ErrInvalidUserID = errors.New("invalid user ID, this must be a valid UUID") ErrAtLeastOneFieldMustBeUpdated = errors.New("at least one field must be updated, any of these could be empty") ErrRequiredUUID = errors.New("required UUID") ErrInvalidUUID = errors.New("invalid UUID") ErrUUIDCannotBeNil = errors.New("UUID cannot be nil") ErrInvalidFilter = errors.New("invalid filter field") ErrInvalidSort = errors.New("invalid sort field") ErrInvalidFields = errors.New("invalid fields field") ErrInvalidLimit = errors.New("invalid limit field") ErrInvalidNextToken = errors.New("invalid nextToken field") ErrInvalidPrevToken = errors.New("invalid prevToken field") ErrInvalidService = errors.New("invalid service") ErrInvalidOpenTelemetry = errors.New("invalid open telemetry") )
var ( ErrInvalidUserFirstName = errors.New("invalid user first name. Must be between" + fmt.Sprintf("%d and %d", UsersFirstNameMinLength, UsersFirstNameMaxLength) + "characters long") ErrInvalidUserLastName = errors.New("invalid user last name. Must be between" + fmt.Sprintf("%d and %d", UsersLastNameMinLength, UsersLastNameMaxLength) + "characters long") ErrInvalidUserEmail = errors.New("invalid user email. Must be between" + fmt.Sprintf("%d and %d", UsersEmailMinLength, UsersEmailMaxLength) + "characters long") ErrInvalidUserPassword = errors.New("invalid user password. Must be at least" + fmt.Sprintf("%d characters long", UsersPasswordMinLength) + "characters long") )
Functions ¶
This section is empty.
Types ¶
type CreateUserRequest ¶
type CreateUserRequest struct { ID uuid.UUID `json:"id" example:"550e8400-e29b-41d4-a716-446655440000" format:"uuid"` FirstName string `json:"first_name" example:"John" format:"string"` LastName string `json:"last_name" example:"Doe" format:"string"` Email string `json:"email" example:"my@email.com" format:"email"` Password string `json:"password" example:"ThisIs4Passw0rd" format:"string"` }
CreateUserRequest represents the input for the CreateUser method.
func (*CreateUserRequest) Validate ¶
func (req *CreateUserRequest) Validate() error
Validate validates the CreateUserRequest.
type HealthHandler ¶
type HealthHandler struct {
// contains filtered or unexported fields
}
HealthHandler represents the handler for the health of the service.
func NewHealthHandler ¶
func NewHealthHandler(us UserService) *HealthHandler
NewHealthHandler returns a new instance of HealthHandler.
func (*HealthHandler) RegisterRoutes ¶
func (h *HealthHandler) RegisterRoutes(mux *http.ServeMux)
RegisterRoutes registers the routes for the handler.
type ListUsersResponse ¶
type ListUsersResponse struct { Items []*User `json:"items"` Paginator paginator.Paginator `json:"paginator"` }
ListUsersResponse represents a list of users.
type PprofHandler ¶
type PprofHandler struct{}
PprofHandler handles the pprof routes
func NewPprofHandler ¶
func NewPprofHandler() *PprofHandler
NewPprofHandler creates a new PprofHandler
func (*PprofHandler) RegisterRoutes ¶
func (h *PprofHandler) RegisterRoutes(mux *http.ServeMux)
RegisterRoutes registers the routes for the handler
type SwaggerHandler ¶
type SwaggerHandler struct {
// contains filtered or unexported fields
}
SwaggerHandler handles the swagger UI
func NewSwaggerHandler ¶
func NewSwaggerHandler(url string) *SwaggerHandler
NewSwaggerHandler creates a new SwaggerHandler
func (*SwaggerHandler) RegisterRoutes ¶
func (h *SwaggerHandler) RegisterRoutes(mux *http.ServeMux)
RegisterRoutes registers the routes for the handler
type UpdateUserRequest ¶
type UpdateUserRequest struct { FirstName *string `json:"first_name" example:"John" format:"string"` LastName *string `json:"last_name" example:"Doe" format:"string"` Email *string `json:"email" example:"my@email.com" format:"email"` Password *string `json:"password" example:"ThisIs4Passw0rd" format:"string"` Disabled *bool `json:"disabled" example:"false" format:"boolean"` }
UpdateUserRequest represents the input for the UpdateUser method.
func (*UpdateUserRequest) Validate ¶
func (req *UpdateUserRequest) Validate() error
type User ¶
type User struct { ID uuid.UUID `json:"id,omitempty" example:"550e8400-e29b-41d4-a716-446655440000" format:"uuid"` FirstName string `json:"first_name,omitempty" example:"John" format:"string"` LastName string `json:"last_name,omitempty" example:"Doe" format:"string"` Email string `json:"email,omitempty" example:"my@email.com" format:"email"` Disabled bool `json:"disabled" example:"false" format:"boolean"` CreatedAt time.Time `json:"created_at,omitempty" example:"2021-01-01T00:00:00Z" format:"date-time"` UpdatedAt time.Time `json:"updated_at,omitempty" example:"2021-01-01T00:00:00Z" format:"date-time"` }
User represents a user entity used to model the data stored in the database.
func (User) MarshalJSON ¶
MarshalJSON marshals the user into JSON. this is needed to omit zero values from the JSON output.
type UserHandler ¶
type UserHandler struct {
// contains filtered or unexported fields
}
UserHandler represents the handler for the user.
func NewUserHandler ¶
func NewUserHandler(conf UserHandlerConf) (*UserHandler, error)
NewUserHandler creates a new UserHandler.
func (*UserHandler) RegisterRoutes ¶
func (h *UserHandler) RegisterRoutes(mux *http.ServeMux)
RegisterRoutes registers the routes on the mux.
type UserHandlerConf ¶
type UserHandlerConf struct { Service UserService OT *o11y.OpenTelemetry MetricsPrefix string }
UserHandler represents the handler for the user.
type UserService ¶
type UserService interface { UserHealthCheck(ctx context.Context) (service.Health, error) GetUserByID(ctx context.Context, id uuid.UUID) (*service.User, error) GetUserByEmail(ctx context.Context, email string) (*service.User, error) CreateUser(ctx context.Context, input *service.CreateUserInput) error UpdateUser(ctx context.Context, input *service.UpdateUserInput) error DeleteUser(ctx context.Context, input *service.DeleteUserInput) error ListUsers(ctx context.Context, input *service.ListUserInput) (*service.ListUsersOutput, error) }
UserService represents the service for the user.
type VersionHandler ¶
type VersionHandler struct{}
VersionHandler represents the handler for the version of the service.
func NewVersionHandler ¶
func NewVersionHandler() *VersionHandler
NewVersionHandler returns a new instance of VersionHandler.
func (*VersionHandler) RegisterRoutes ¶
func (h *VersionHandler) RegisterRoutes(mux *http.ServeMux)
RegisterRoutes registers the routes for the version of the service.