api

package
v0.0.0-...-33d7a3f Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AvailablePlayers

type AvailablePlayers struct {
	Players []model.Player `json:"players"`
}

type ControllerPlayer

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

ControllerPlayer handles all the player persist logic

func (*ControllerPlayer) GetPlayerByID

func (cp *ControllerPlayer) GetPlayerByID(id string) (model.Player, error)

GetPlayerByID (GET /players/:id) check in the DB the player finding by id

func (*ControllerPlayer) GetPlayerByNickname

func (cp *ControllerPlayer) GetPlayerByNickname(nickname string) (model.Player, error)

GetPlayerByNickname (GET /players/) found a player by their nickname

func (*ControllerPlayer) GetPlayers

func (cp *ControllerPlayer) GetPlayers() ([]model.Player, error)

GetPlayers (GET /players) check in the DB all the stored players and return them in JSON format

func (*ControllerPlayer) GetPlayersRankedBy

func (cp *ControllerPlayer) GetPlayersRankedBy(sortField string, sortFields ...string) ([]model.Player, error)

GetPlayersRankedBy : sortField (might be elo, rank, age) | sortFields (optional) - list of more fields to sort (GET /players) returns all the players sorted by their elo, maybe you can think "ok, but you can use getplayers and then sort it" but no... queries in an SQL motor are more performant than in the code

func (*ControllerPlayer) Init

func (cp *ControllerPlayer) Init(db *psdb.PostgreDB)

func (*ControllerPlayer) UpdatePlayers

func (cp *ControllerPlayer) UpdatePlayers(matchResult model.Result) (int64, error)

UpdatePlayers (POST /players/:id/update) updates the players fields given a match result and return the updated rows count (NOTE: this function receives a map[int]int that contains the id of the player and the goals

type Router

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

func (*Router) Init

func (r *Router) Init(postgreDB *psdb.PostgreDB)

func (*Router) StartRouter

func (r *Router) StartRouter()

StartRouter turns on the gin-gonic server and initialize the entire REST-API routes and endpoints

Jump to

Keyboard shortcuts

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