Documentation
¶
Index ¶
- Constants
- func NewMiddleware(service Service, logger log.Logger) middleware
- func RegisterHandlers(g *echo.Group, service Service, logger log.Logger, ...)
- func WithFilters(ctx context.Context, value map[string][]string) context.Context
- type Comment
- type CreateCommentRequest
- type Repository
- type Service
- type UpdateCommentRequest
Constants ¶
View Source
const ( // filtersKey identifies the current filters during the request life. FiltersKey contextKey = iota )
Variables ¶
This section is empty.
Functions ¶
func NewMiddleware ¶ added in v0.4.0
NewMiddleware creates a new user Middleware.
func RegisterHandlers ¶
func RegisterHandlers(g *echo.Group, service Service, logger log.Logger, requireLogin echo.MiddlewareFunc, verifyID echo.MiddlewareFunc)
Types ¶
type CreateCommentRequest ¶
type CreateCommentRequest struct {
Body string `json:"body" validate:"required"`
SHA256 string `json:"sha256" validate:"required,alphanum,len=64"`
Username string
}
CreateCommentRequest represents a comment creation request.
type Repository ¶
type Repository interface {
// Get returns the comment with the specified comment ID.
Get(ctx context.Context, id string, fields []string) (entity.Comment, error)
// Create saves a new comment in the storage.
Create(ctx context.Context, Comment entity.Comment) error
// Update updates the comment with given ID in the storage.
Update(ctx context.Context, User entity.Comment) error
// Delete removes the comment with given ID from the storage.
Delete(ctx context.Context, id string) error
// Exists checks if a comment exists with a given ID.
Exists(ctx context.Context, id string) (bool, error)
// Count returns the number of comments.
Count(ctx context.Context) (int, error)
// Query returns the list of comments with the given offset and limit.
Query(ctx context.Context, offset, limit int, fields []string) ([]entity.Comment, error)
}
Repository encapsulates the logic to access comments from the data source.
func NewRepository ¶
func NewRepository(db *dbcontext.DB, logger log.Logger) Repository
NewRepository creates a new comment repository.
type Service ¶
type Service interface {
Exists(ctx context.Context, id string) (bool, error)
Get(ctx context.Context, id string, fields []string) (Comment, error)
Create(ctx context.Context, input CreateCommentRequest) (Comment, error)
Update(ctx context.Context, id string, input UpdateCommentRequest) (Comment, error)
Delete(ctx context.Context, id string) (Comment, error)
Count(ctx context.Context) (int, error)
Query(ctx context.Context, offset, limit int, fields []string) ([]Comment, error)
}
Service encapsulates usecase logic for files.
func NewService ¶
func NewService(repo Repository, logger log.Logger, actSvc activity.Service, userSvc user.Service) Service
NewService creates a new user service.
type UpdateCommentRequest ¶ added in v0.4.0
type UpdateCommentRequest struct {
Body string `json:"body" validate:"required"`
}
UpdateCommentRequest represents a comment update request.
Click to show internal directories.
Click to hide internal directories.