Documentation
¶
Overview ¶
Package controller holds application controllers.
Index ¶
- type Controller
- func (c *Controller) DeleteUser(w http.ResponseWriter, r *http.Request)
- func (c *Controller) FindUsers(w http.ResponseWriter, r *http.Request)
- func (c *Controller) GetUser(w http.ResponseWriter, r *http.Request)
- func (c *Controller) Mux() *mux.Router
- func (c *Controller) NewUser(w http.ResponseWriter, r *http.Request)
- func (c *Controller) UpdateUser(w http.ResponseWriter, r *http.Request)
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller - controller related struct
func New ¶
func New(service Service) *Controller
New - Instantiates a new Controller. Requires a Service.
func (*Controller) DeleteUser ¶
func (c *Controller) DeleteUser(w http.ResponseWriter, r *http.Request)
DeleteUser - Handles a user deletion. Requires the user ID to be removed. Returns OK or an error in case of failure.
func (*Controller) FindUsers ¶ added in v0.8.0
func (c *Controller) FindUsers(w http.ResponseWriter, r *http.Request)
FindUsers - Gets all users using pagination Optionally should be sent offset or limit pagination values. Returns OK or an error in case of failure.
func (*Controller) GetUser ¶
func (c *Controller) GetUser(w http.ResponseWriter, r *http.Request)
GetUser - Handles a get user request. Requires a URL parameter ID. Returns a user ID or an error in case of failure.
func (*Controller) Mux ¶ added in v0.4.3
func (c *Controller) Mux() *mux.Router
Mux - Initializes routing and returns a Router.
func (*Controller) NewUser ¶
func (c *Controller) NewUser(w http.ResponseWriter, r *http.Request)
NewUser - Handles a user creation request. Requires a user data JSON body. Returns the created user or an error in case of failure.
func (*Controller) UpdateUser ¶
func (c *Controller) UpdateUser(w http.ResponseWriter, r *http.Request)
UpdateUser - Handles a user update request. Requires the user ID to update and a user data JSON body. Returns the updated user or an error in case of failure.
type Service ¶
type Service interface {
FindUser(ctx context.Context, id string) (model.User, error)
CreateUser(ctx context.Context, user model.User) (model.User, error)
UpdateUser(ctx context.Context, id string, userUpdate request.UserUpdate) (model.User, error)
DeleteUser(ctx context.Context, id string) error
FindAllUsers(ctx context.Context, offset int64, limit int64) ([]model.User, error)
}
Service abstracts the service layer.