Documentation ¶
Index ¶
- func NewUserRoutes(logger logger.Logger, handler common.RequestHandler, ...) routes.Route
- type CreateUserRequest
- type UpdateUserRequest
- type UserAPIConverter
- type UserController
- func (u UserController) CreateUser(ctx *gin.Context) (*response.APIResponseEnvelope, error)
- func (u UserController) DeleteUserByID(ctx *gin.Context) (*response.APIResponseEnvelope, error)
- func (u UserController) FindAllUsers(ctx *gin.Context) (*response.APIResponseEnvelope, error)
- func (u UserController) FindOneUserByID(ctx *gin.Context) (*response.APIResponseEnvelope, error)
- func (u UserController) Overview(ctx *gin.Context) (*response.APIResponseEnvelope, error)
- func (u UserController) UpdateUser(ctx *gin.Context) (*response.APIResponseEnvelope, error)
- type UserOverviewAPIConverter
- type UserRoutes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewUserRoutes ¶
func NewUserRoutes( logger logger.Logger, handler common.RequestHandler, userController UserController, rootHandler *routeHandlers.RootRouteHandler, ) routes.Route
NewUserRoutes creates new user routes.
Types ¶
type CreateUserRequest ¶
type CreateUserRequest struct { Name string `json:"name" binding:"required" example:"Name"` // TODO, apply validation Email string `json:"email" binding:"required" example:"Name@name.com"` Age uint8 `json:"age" binding:"required" example:"50"` Birthday types.Date `json:"birthday" binding:"required" example:"2022-06-10"` }
type UpdateUserRequest ¶
type UserAPIConverter ¶
type UserAPIConverter interface { converters.APIResponseConverter[*entities.User, response.UserResponse] converters.APIRequestCreateConverter[CreateUserRequest, entities.User] converters.APIRequestUpdateConverter[UpdateUserRequest, entities.User] }
func NewUserAPIConverter ¶
func NewUserAPIConverter(userService domain.UserService) UserAPIConverter
type UserController ¶
type UserController struct {
// contains filtered or unexported fields
}
UserController is a struct which handles the typical http requests for a user.
func NewUserController ¶
func NewUserController( userService services.UserService, logger logger.Logger, apiConverter UserAPIConverter, overviewAPIConverter UserOverviewAPIConverter, validator binding.StructValidator, ) UserController
NewUserController creates a new NewUserController.
func (UserController) CreateUser ¶
func (u UserController) CreateUser(ctx *gin.Context) (*response.APIResponseEnvelope, error)
CreateUser creates a user using the prerequisites provided. @Param request body CreateUserRequest true "query params" @Summary Creates a user using the prerequisites provided @Success 201 {object} response.UserResponse "if a new user was created" @Failure 400 {object} response.APIErrorResponse "in case of a bad request" @Router /users [post].
func (UserController) DeleteUserByID ¶
func (u UserController) DeleteUserByID(ctx *gin.Context) (*response.APIResponseEnvelope, error)
DeleteUserByID deletes a user by id. @Summary Deletes a user by id. @Success 204 "if the user is deleted successfully" @Failure 400 {object} response.APIErrorResponse "in case of a bad request" @Failure 500 {object} response.APIErrorResponse "in case of an internal error" @Router /users/{id} [delete].
func (UserController) FindAllUsers ¶
func (u UserController) FindAllUsers(ctx *gin.Context) (*response.APIResponseEnvelope, error)
FindAllUsers retrieves paginated response of users. @Summary Retrieves paginated response of users @Success 200 {object} response.PageableResponse[response.UserResponse] @Failure 400 {object} response.APIErrorResponse "in case of an error" @Router /users [get].
func (UserController) FindOneUserByID ¶
func (u UserController) FindOneUserByID(ctx *gin.Context) (*response.APIResponseEnvelope, error)
FindOneUserByID retrieves a user by the provided ID. @Summary Retrieves a user by the provided ID. @Success 200 {object} response.PageableResponse[response.UserResponse] @Failure 400 {object} response.APIErrorResponse "in case of a bad request" @Failure 404 {object} response.APIErrorResponse "if an unknown ID is provided" @Router /users/{id} [get].
func (UserController) Overview ¶
func (u UserController) Overview(ctx *gin.Context) (*response.APIResponseEnvelope, error)
Overview retrieves overview information about users. @Summary Retrieves paginated response of users @Success 200 {object} response.PageableResponse[response.UserResponse] @Failure 400 {object} response.APIErrorResponse "in case of an error" @Router /users/overview [get].
func (UserController) UpdateUser ¶
func (u UserController) UpdateUser(ctx *gin.Context) (*response.APIResponseEnvelope, error)
UpdateUser updates an existing user. @Summary Updates an existing user. @Success 200 {object} response.UserResponse "the updated users" @Failure 400 {object} response.APIErrorResponse "in case of a bad request" @Failure 500 {object} response.APIErrorResponse "in case of an internal error" @Router /users/{id} [post].
type UserOverviewAPIConverter ¶
type UserOverviewAPIConverter interface { converters.APIResponseConverter[*models.SenderOverview, response.UserOverviewResponse] }
func NewUserOverviewAPIConverter ¶
func NewUserOverviewAPIConverter() UserOverviewAPIConverter
type UserRoutes ¶
type UserRoutes struct {
// contains filtered or unexported fields
}
UserRoutes struct.