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 Items API methods.
Types ¶
type ItemFilter ¶
type Repository ¶
type Repository interface { // GetAll returns all items in the application. GetAll(userId int, filters ItemFilter) ([]entity.Item, error) // GetOne returns user's item with specified id. GetOne(userId, itemId int) (entity.Item, error) // Update modifies the user's item status with specified id. Update(userId int, item *entity.Item) error }
Repository encapsulates the logic to access items from the data source.
func NewRepository ¶
func NewRepository(db *sql.DB, logger log.Logger) Repository
NewRepository creates a new item's repository.
type Service ¶
type Service interface { // GetAll returns all items. GetAll(userId int, filters ItemFilter) ([]entity.Item, error) // GetOne returns item with specified id owned by user with specified id. GetOne(userId, itemId int) (entity.Item, error) // UpdateItemState returns item with specified id with new ItemState. UpdateItemState(userId, itemId int, input *UpdateItemStateRequest) (entity.Item, error) }
Service encapsulates usecase logic for items.
type UpdateItemStateRequest ¶
UpdateItemStateRequest represents the data for modifing ItemState.
Click to show internal directories.
Click to hide internal directories.