Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
UserService UserService
}
Handler is a struct for injected services
func (*Handler) Create ¶
Create godoc @Summary Create user @Description Add user to database @Tags user @Accept json @Produce json @Param user body createPayload true "Add user" @Success 201 {object} model.User @Failure 400 {object} rerrors.Error "Validation error" @Failure 409 {object} rerrors.Error "Unique Violation" @Failure 500 {object} rerrors.Error "Internal Server Error" @Router /users [post]
func (*Handler) Delete ¶
Delete godoc @Summary Delete user @Description Delete user @Tags user @ID string @Accept json @Produce json @Param id path string true "User ID" @Success 204 @Failure 404 {object} rerrors.Error "User Not Found" @Router /users/{id} [delete]
func (*Handler) GetAll ¶
GetAll godoc @Summary Get all users @Description Fetch all users from database. Can filter by name. @Tags user @Accept json @Produce json @Param name query string false "search by name" @Success 200 {object} []model.User @Success 204 @Failure 500 {object} rerrors.Error "Internal Server Error" @Router /users [get]
func (*Handler) GetByID ¶
GetByID godoc @Summary Get a single user by ID @Description Get a single user by ID @Tags user @ID string @Accept json @Produce json @Param id path string true "User ID" @Success 200 {object} model.User @Failure 400 {object} rerrors.Error "Bad Request. Invalid ID" @Failure 404 {object} rerrors.Error "User Not Found" @Router /users/{id} [get]
func (*Handler) Update ¶
Update godoc @Summary Update user @Description Update user @Tags user @ID string @Accept json @Produce json @Param id path string true "User ID" @Param user body updatePayload false "Update user" @Success 200 {object} model.User @Failure 400 {object} rerrors.Error "Validation error" @Failure 409 {object} rerrors.Error "Unique Violation" @Failure 500 {object} rerrors.Error "Internal Server Error" @Router /users/{id} [put]
type UserService ¶
type UserService interface { GetAll(ctx context.Context, name string) ([]model.User, error) GetByID(ctx context.Context, id string) (*model.User, error) Create(ctx context.Context, u *model.User) (*model.User, error) Update(ctx context.Context, id string, u *model.User) (*model.User, error) Delete(ctx context.Context, id string) error }
UserService represents the user service implementation