players

package
v0.0.0-...-c8194c3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(logger *slog.Logger, db PlayerDB) *API

func (*API) GetPlayer

func (a *API) GetPlayer(c *gin.Context)

swagger:route GET /player/{ID} player getPlayer

Get a player by ID.

responses:

200: body:GetPlayerResp
400: body:Error
500: body:Error

func (*API) GetPlayers

func (a *API) GetPlayers(c *gin.Context)

swagger:route GET /players player getPlayers

Get all players.

responses:

200: body:GetPlayersResp
500: body:Error

func (*API) PostPlayer

func (a *API) PostPlayer(c *gin.Context)

swagger:route POST /player player postPlayer

Add a new player.

responses:

200: body:PostPlayerResp
400: body:Error
500: body:Error

func (*API) PutPlayer

func (a *API) PutPlayer(c *gin.Context)

swagger:route PUT /player/{ID} player putPlayer

Update a player.

responses:

200: body:PutPlayerResp
400: body:Error
500: body:Error

type GetPlayerInput

type GetPlayerInput struct {
	// in:path
	ID uuid.UUID
}

swagger:parameters getPlayer

type GetPlayerResp

type GetPlayerResp struct {
	Data Player `json:"data"`
}

swagger:model GetPlayerResp

type GetPlayersResp

type GetPlayersResp struct {
	Data []Player `json:"data"`
}

swagger:model GetPlayersResp

type Player

type Player struct {
	ID        string `json:"id"`
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
}

swagger:model Player

type PlayerDB

type PlayerDB interface {
	AddPlayer(ctx context.Context, newPlayer model.Player) (*model.Player, error)
	GetPlayer(ctx context.Context, id uuid.UUID) (*model.Player, error)
	GetAllPlayers(ctx context.Context) ([]model.Player, error)
	UpdatePlayer(ctx context.Context, id uuid.UUID, Player db.UpdatePlayerInput) (*model.Player, error)
}

type PostPlayerInput

type PostPlayerInput struct {
	// in:body
	Body struct {
		// required: true
		FirstName string `json:"firstName" binding:"required,ascii"`
		// required: true
		LastName string `json:"lastName" binding:"required"`
	}
}

swagger:parameters postPlayer

type PostPlayerResp

type PostPlayerResp struct {
	Data Player `json:"data"`
}

swagger:model PostPlayerResp

type PutPlayerInput

type PutPlayerInput struct {
	// in:path
	ID uuid.UUID
	// in:body
	Body struct {
		// required: true
		FirstName string `json:"firstName" binding:"required,ascii"`
		// required: true
		LastName string `json:"lastName" binding:"required"`
	}
}

swagger:parameters putPlayer

type PutPlayerResp

type PutPlayerResp struct {
	Data Player `json:"data"`
}

swagger:model PutPlayerResp

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL