Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterHandlers ¶
func RegisterHandlers(r *routing.RouteGroup, service Service, authHandler routing.Handler, logger log.Logger)
RegisterHandlers sets up the routing of the HTTP handlers.
Types ¶
type CreateAlbumRequest ¶
type CreateAlbumRequest struct {
Name string `json:"name"`
}
CreateAlbumRequest represents an album creation request.
func (CreateAlbumRequest) Validate ¶
func (m CreateAlbumRequest) Validate() error
Validate validates the CreateAlbumRequest fields.
type Repository ¶
type Repository interface {
// Get returns the album with the specified album ID.
Get(ctx context.Context, id string) (entity.Album, error)
// Count returns the number of albums.
Count(ctx context.Context) (int, error)
// Query returns the list of albums with the given offset and limit.
Query(ctx context.Context, offset, limit int) ([]entity.Album, error)
// Create saves a new album in the storage.
Create(ctx context.Context, album entity.Album) error
// Update updates the album with given ID in the storage.
Update(ctx context.Context, album entity.Album) error
// Delete removes the album with given ID from the storage.
Delete(ctx context.Context, id string) error
}
Repository encapsulates the logic to access albums from the data source.
func NewRepository ¶
func NewRepository(db *dbx.DB, logger log.Logger) Repository
NewRepository creates a new album repository
type Service ¶
type Service interface {
Get(ctx context.Context, id string) (Album, error)
Query(ctx context.Context, offset, limit int) ([]Album, error)
Count(ctx context.Context) (int, error)
Create(ctx context.Context, input CreateAlbumRequest) (Album, error)
Update(ctx context.Context, id string, input UpdateAlbumRequest) (Album, error)
Delete(ctx context.Context, id string) (Album, error)
}
Service encapsulates usecase logic for albums.
func NewService ¶
func NewService(repo Repository, logger log.Logger) Service
NewService creates a new album service.
type UpdateAlbumRequest ¶
type UpdateAlbumRequest struct {
Name string `json:"name"`
}
UpdateAlbumRequest represents an album update request.
func (UpdateAlbumRequest) Validate ¶
func (m UpdateAlbumRequest) Validate() error
Validate validates the CreateAlbumRequest fields.
Click to show internal directories.
Click to hide internal directories.