Documentation
¶
Index ¶
- func Service(log *zap.Logger, db *pgxpool.Pool, au *auth.Client, pr *Provider, ...) (http.Server, error)
- type Decoder
- type GameFacade
- type Provider
- func (p *Provider) CreateGame(w http.ResponseWriter, r *http.Request)
- func (p *Provider) DeleteGame(w http.ResponseWriter, r *http.Request)
- func (p *Provider) GetGame(w http.ResponseWriter, r *http.Request)
- func (p *Provider) GetGames(w http.ResponseWriter, r *http.Request)
- func (p *Provider) GetGenres(w http.ResponseWriter, r *http.Request)
- func (p *Provider) GetPlatforms(w http.ResponseWriter, r *http.Request)
- func (p *Provider) GetTopCompanies(w http.ResponseWriter, r *http.Request)
- func (p *Provider) GetTopGenres(w http.ResponseWriter, r *http.Request)
- func (p *Provider) GetUserRatings(w http.ResponseWriter, r *http.Request)
- func (p *Provider) RateGame(w http.ResponseWriter, r *http.Request)
- func (p *Provider) UpdateGame(w http.ResponseWriter, r *http.Request)
- func (p *Provider) UploadGameImages(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GameFacade ¶
type GameFacade interface { GetGames(ctx context.Context, page, pageSize int, filter model.GamesFilter) (games []model.Game, count uint64, err error) GetGameByID(ctx context.Context, id int32) (model.Game, error) CreateGame(ctx context.Context, cg model.CreateGame) (id int32, err error) UpdateGame(ctx context.Context, id int32, upd model.UpdateGame) error DeleteGame(ctx context.Context, id int32, publisher string) error RateGame(ctx context.Context, gameID int32, userID string, rating uint8) error GetUserRatings(ctx context.Context, userID string) (map[int32]uint8, error) UploadGameImages(ctx context.Context, coverFiles, screenshotFiles []*multipart.FileHeader, publisherName string) ([]model.File, error) GetGenres(ctx context.Context) ([]model.Genre, error) GetGenresMap(ctx context.Context) (map[int32]model.Genre, error) GetTopGenres(ctx context.Context, limit int64) ([]model.Genre, error) GetPlatforms(ctx context.Context) ([]model.Platform, error) GetPlatformsMap(ctx context.Context) (map[int32]model.Platform, error) GetCompaniesMap(ctx context.Context) (map[int32]model.Company, error) GetTopCompanies(ctx context.Context, companyType string, limit int64) ([]model.Company, error) }
GameFacade represents methods for working with games
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider has all dependencies for handlers
func NewProvider ¶
func NewProvider(log *zap.Logger, redisStore *cache.RedisStore, gameFacade GameFacade, decoder Decoder) *Provider
NewProvider creates new provider
func (*Provider) CreateGame ¶
func (p *Provider) CreateGame(w http.ResponseWriter, r *http.Request)
CreateGame godoc @Summary Create game @Description creates new game @Security BearerAuth @ID create-game @Accept json @Produce json @Param game body api.CreateGameRequest true "create game" @Success 201 {object} api.IDResponse @Failure 400 {object} web.ErrorResponse @Failure 429 {object} web.ErrorResponse @Failure 500 {object} web.ErrorResponse @Router /games [post]
func (*Provider) DeleteGame ¶
func (p *Provider) DeleteGame(w http.ResponseWriter, r *http.Request)
DeleteGame godoc @Summary Delete game @Description deletes game by ID @Security BearerAuth @ID delete-game @Accept json @Produce json @Param id path int32 true "Game ID" @Success 204 @Failure 400 {object} web.ErrorResponse @Failure 403 {object} web.ErrorResponse @Failure 404 {object} web.ErrorResponse @Failure 500 {object} web.ErrorResponse @Router /games/{id} [delete]
func (*Provider) GetGame ¶
func (p *Provider) GetGame(w http.ResponseWriter, r *http.Request)
GetGame godoc @Summary Get game @Description returns game by ID @ID get-game-by-id @Produce json @Param id path int32 true "Game ID" @Success 200 {object} api.GameResponse @Failure 400 {object} web.ErrorResponse @Failure 404 {object} web.ErrorResponse @Failure 500 {object} web.ErrorResponse @Router /games/{id} [get]
func (*Provider) GetGames ¶
func (p *Provider) GetGames(w http.ResponseWriter, r *http.Request)
GetGames godoc @Summary Get games @Description returns paginated games @ID get-games @Produce json @Param pageSize query int32 false "page size" @Param page query int32 false "page" @Param orderBy query string false "order by" Enums(default, name, releaseDate) @Param name query string false "name filter" @Param genre query int32 false "genre filter" @Param developer query int32 false "developer id filter" @Param publisher query int32 false "publisher id filter" @Success 200 {object} api.GamesResponse @Failure 500 {object} web.ErrorResponse @Router /games [get]
func (*Provider) GetGenres ¶
func (p *Provider) GetGenres(w http.ResponseWriter, r *http.Request)
GetGenres godoc @Summary Get genres @Description returns all genres @ID get-genres @Produce json @Success 200 {array} api.Genre @Failure 500 {object} web.ErrorResponse @Router /genres [get]
func (*Provider) GetPlatforms ¶
func (p *Provider) GetPlatforms(w http.ResponseWriter, r *http.Request)
GetPlatforms godoc @Summary Get platforms @Description returns all platforms @ID get-platforms @Produce json @Success 200 {array} api.Platform @Failure 500 {object} web.ErrorResponse @Router /platforms [get]
func (*Provider) GetTopCompanies ¶
func (p *Provider) GetTopCompanies(w http.ResponseWriter, r *http.Request)
GetTopCompanies godoc @Summary Get top companies @Description returns top companies based on amount of games having it @ID get-top-companies @Produce json @Param type query string true "company type (dev or pub)" Enums(pub, dev) @Success 200 {array} api.Company @Failure 400 {object} web.ErrorResponse "Invalid or missing company type" @Failure 500 {object} web.ErrorResponse @Router /companies/top [get]
func (*Provider) GetTopGenres ¶
func (p *Provider) GetTopGenres(w http.ResponseWriter, r *http.Request)
GetTopGenres godoc @Summary Get top genres @Description returns top genres based on amount of games having it @ID get-top-genres @Produce json @Success 200 {array} api.Genre @Failure 500 {object} web.ErrorResponse @Router /genres/top [get]
func (*Provider) GetUserRatings ¶
func (p *Provider) GetUserRatings(w http.ResponseWriter, r *http.Request)
GetUserRatings godoc @Summary Get user ratings for specified games @Description returns user ratings for specified games @ID get-user-ratings @Produce json @Param gameIds body api.GetUserRatingsRequest true "games ids" @Success 200 {object} map[int32]uint8 @Failure 400 {object} web.ErrorResponse @Failure 500 {object} web.ErrorResponse @Router /user/ratings [post]
func (*Provider) RateGame ¶
func (p *Provider) RateGame(w http.ResponseWriter, r *http.Request)
RateGame godoc @Summary Rate game @Description rates game @Security BearerAuth @ID rate-game @Accept json @Produce json @Param id path int32 true "game ID" @Param rating body api.CreateRatingRequest true "game rating" @Success 200 {object} api.RatingResponse @Failure 400 {object} web.ErrorResponse @Failure 404 {object} web.ErrorResponse @Failure 500 {object} web.ErrorResponse @Router /games/{id}/rate [post]
func (*Provider) UpdateGame ¶
func (p *Provider) UpdateGame(w http.ResponseWriter, r *http.Request)
UpdateGame godoc @Summary Update game @Description updates game by ID @Security BearerAuth @ID update-game @Accept json @Produce json @Param id path int32 true "Game ID" @Param game body api.UpdateGameRequest true "update game" @Success 204 @Failure 400 {object} web.ErrorResponse @Failure 403 {object} web.ErrorResponse @Failure 404 {object} web.ErrorResponse @Failure 500 {object} web.ErrorResponse @Router /games/{id} [patch]
func (*Provider) UploadGameImages ¶
func (p *Provider) UploadGameImages(w http.ResponseWriter, r *http.Request)
UploadGameImages godoc @Summary Upload game images @Description uploads cover and screenshots images @Security BearerAuth @ID upload-game-images @Accept multipart/form-data @Produce json @Param cover formData file false "Cover image file (.png, .jpg, .jpeg), maximum 1MB" @Param screenshots formData []file false "Screenshot image files (.png, .jpg, .jpeg), up to 8 files, maximum 1MB each" collectionFormat(multi) @Success 201 {object} api.UploadImagesResponse @Failure 400 {object} web.ErrorResponse @Failure 429 {object} web.ErrorResponse @Failure 500 {object} web.ErrorResponse @Router /games/images [post]
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package api_mock is a generated GoMock package.
|
Package api_mock is a generated GoMock package. |