Documentation
¶
Index ¶
- Variables
- type Challenge
- type FileMeta
- type FileService
- type Handler
- func (h *Handler) AddChallengeFile(c *gin.Context)
- func (h *Handler) CreateChallenge(c *gin.Context)
- func (h *Handler) DeleteChallenge(c *gin.Context)
- func (h *Handler) DeleteChallengeFile(c *gin.Context)
- func (h *Handler) DownloadChallengeFile(c *gin.Context)
- func (h *Handler) GetChallenge(c *gin.Context)
- func (h *Handler) GetChallenges(c *gin.Context)
- func (h *Handler) GetFlag(c *gin.Context)
- func (h *Handler) GetSolves(c *gin.Context)
- func (h *Handler) UpdateChallenge(c *gin.Context)
- func (h *Handler) UpdateChallengeFile(c *gin.Context)
- type Repository
- func (r *Repository) Create(ctx context.Context, c *Challenge) error
- func (r *Repository) Delete(ctx context.Context, id string) error
- func (r *Repository) GetAll(ctx context.Context) ([]Challenge, error)
- func (r *Repository) GetByID(ctx context.Context, id string) (*Challenge, error)
- func (r *Repository) Update(ctx context.Context, id string, update any) error
- type Service
- func (s *Service) AddChallengeFile(ctx context.Context, id string, form *multipart.Form, gc *gin.Context) ([]FileMeta, error)
- func (s *Service) CleanOrphanFileUploads(ctx context.Context) ([]string, error)
- func (s *Service) CreateChallenge(ctx context.Context, c *Challenge) error
- func (s *Service) CreateChallengeWithFiles(ctx context.Context, c *Challenge, form *multipart.Form, gc *gin.Context) error
- func (s *Service) DeleteChallenge(ctx context.Context, id string) error
- func (s *Service) DeleteChallengeFile(ctx context.Context, id string, fileUUID string, gc *gin.Context) error
- func (s *Service) FileExistsInChallenge(ctx context.Context, id, fileUUID string) (*FileMeta, error)
- func (s *Service) GetChallenge(ctx context.Context, id string) (*Challenge, error)
- func (s *Service) GetChallengeFile(ctx context.Context, id, fileUUID string) (string, string, error)
- func (s *Service) ListChallenges(ctx context.Context) ([]Challenge, error)
- func (s *Service) UpdateChallenge(ctx context.Context, id string, update *UpdateChallengeRequest) error
- func (s *Service) UpdateChallengeFile(ctx context.Context, id string, fileUUID string, form *multipart.Form, ...) error
- type UpdateChallengeRequest
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoFile = errors.New("uploaded files not found") ErrFileExcedLimit = errors.New("file size exceeds limit") ErrFileNotOnStorage = errors.New("file not found on storage") )
View Source
var (
ErrFileNotFound = errors.New("file not found")
)
Functions ¶
This section is empty.
Types ¶
type Challenge ¶
type Challenge struct { ID bson.ObjectID `bson:"_id,omitempty" json:"id"` Title string `bson:"title" json:"title"` Category string `bson:"category" json:"category"` Description string `bson:"description" json:"description"` Points int `bson:"points" json:"points"` State string `bson:"state" json:"state"` Type string `bson:"type" json:"type"` Solves int `bson:"solves" json:"solves"` Flag string `bson:"flag" json:"flag"` Author string `bson:"author,omitempty" json:"author,omitempty"` Files []FileMeta `bson:"files,omitempty" json:"files,omitempty"` }
type FileService ¶
type FileService struct {
// contains filtered or unexported fields
}
func NewFileService ¶
func NewFileService() *FileService
func (*FileService) ValidateFile ¶
func (fs *FileService) ValidateFile(file *FileMeta) (string, error)
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func (*Handler) AddChallengeFile ¶
func (*Handler) CreateChallenge ¶
func (*Handler) DeleteChallenge ¶
func (*Handler) DeleteChallengeFile ¶
func (*Handler) DownloadChallengeFile ¶
func (*Handler) GetChallenge ¶
func (*Handler) GetChallenges ¶
func (*Handler) UpdateChallenge ¶
func (*Handler) UpdateChallengeFile ¶
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(db *mongo.Database) *Repository
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(repo *Repository) *Service
func (*Service) AddChallengeFile ¶
func (*Service) CleanOrphanFileUploads ¶
func (*Service) CreateChallenge ¶
func (*Service) CreateChallengeWithFiles ¶
func (*Service) DeleteChallenge ¶
func (*Service) DeleteChallengeFile ¶
func (*Service) FileExistsInChallenge ¶
func (*Service) GetChallenge ¶
func (*Service) GetChallengeFile ¶
func (*Service) ListChallenges ¶
func (*Service) UpdateChallenge ¶
type UpdateChallengeRequest ¶
type UpdateChallengeRequest struct { Title *string `bson:"title" json:"title"` Category *string `bson:"category" json:"category"` Description *string `bson:"description" json:"description"` Points *int `bson:"points" json:"points"` State *string `bson:"state" json:"state"` Type *string `bson:"type" json:"type"` Solves *int `bson:"solves" json:"solves"` Flag *string `bson:"flag" json:"flag"` Author *string `bson:"author" json:"author"` }
Click to show internal directories.
Click to hide internal directories.