Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterHandlers ¶
func RegisterHandlers(mux *httprouter.Router, service Service, logger log.Logger)
RegisterHandlers registers handlers for Users API methods.
Types ¶
type CreateUserRequest ¶
type CreateUserRequest struct { Email Email `json:"email"` Nickname Nickname `json:"nickname"` Password Password `json:"password"` }
CreateUserRequest represents the data for creating new User.
type Repository ¶
type Repository interface { // Create saves new user in storage. Create(user *entity.User) error // Get returns User with specified id. Get(id int64) (entity.User, error) // Delete removes User with specified id. Delete(id int64) error // Update modifies User. Update(user *entity.User) error // InitUserInventory init the list of items for user with spec id. InitUserInventory(id int64) error // CleanUserInventory deletes the list of items for user with spec id. CleanUserInventory(id int64) error }
Repository encapsulates the logic to access users from the data source.
func NewRepository ¶
func NewRepository(db *sql.DB, logger log.Logger) Repository
NewRepository creates a new users repository.
type Service ¶
type Service interface { Get(id int64) (User, error) Delete(id int64) (User, error) Create(input *CreateUserRequest) (User, error) Update(id int64, input *UpdateUserRequest) (User, error) }
Service encapsulates usecase logic for users.
type UpdateUserRequest ¶
type UpdateUserRequest struct { Email *Email `json:"email"` Nickname *Nickname `json:"nickname"` NewPassword *Password `json:"newPassword"` CurrentPassword Password `json:"currentPassword"` }
UpdateUserRequest represents the data for modifing User. Fields Email, Nickname and NewPassword are optional.
Click to show internal directories.
Click to hide internal directories.