Documentation ¶
Index ¶
- Variables
- type Config
- type CountResp
- type ErrorResp
- type GameFargoHotHandicapPatchBody
- type GameFargoHotHandicapPatchResp
- type GamePlayersDeleteBody
- type GamePlayersFlagPatchBody
- type GamePlayersNamePatchBody
- type GamePlayersPatchBody
- type GameRaceToPatchBody
- type GameRaceToResp
- type GameScorePatchBody
- type GameScoreResp
- type GameTeamsPatchBody
- type GameTypePatchBody
- type GameTypeResp
- type GameVsModePatchBody
- type GameVsModeResp
- type OverlayToggleFargoResp
- type OverlayToggleFlagsResp
- type OverlayToggleResp
- type OverlayToggleScoreResp
- type PlayersPatchBody
- type PlayersPostBody
- type Server
- func (server *Server) AddRoute(path string, handler http.Handler)
- func (server *Server) AddRouteToAllVersions(path string, handler http.Handler)
- func (server *Server) AddRouteToVersion(version string, path string, handler http.Handler)
- func (server *Server) AddVersion(version string)
- func (server *Server) HandleOptions(w http.ResponseWriter, r *http.Request)
- func (server *Server) Handler() http.Handler
- func (server *Server) Init()
- func (server *Server) InitRoutes()
- func (server *Server) Run() error
- func (server *Server) SetupResponse(w http.ResponseWriter, r *http.Request)
- type TournamentLoadBody
- type TournamentLoadBodySettings
- type Version
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEndpointMethodNotAllowed - Method supplied was not allowed. ErrEndpointMethodNotAllowed = errors.New("method not allowed") // ErrEndpointForbidden - API endpoint forbidden. ErrEndpointForbidden = errors.New("forbidden") // ErrInvalidPageNumber - Invalid page number. ErrInvalidPageNumber = errors.New("invalid page number") // ErrInternalServerError - Internal server error. ErrInternalServerError = errors.New("internal server error") // ErrInvalidPlayerID - Invalid player id. ErrInvalidPlayerID = errors.New("invalid player id") // ErrPlayerNotFound - Player not found. ErrPlayerNotFound = errors.New("player not found") // ErrInvalidPlayerDetails - Invalid player details. ErrInvalidPlayerDetails = errors.New("invalid player details") // ErrInvalidTeamID - Invalid team id. ErrInvalidTeamID = errors.New("invalid team id") // ErrTeamNotFound - Team not found. ErrTeamNotFound = errors.New("team not found") // ErrInvalidGameType - Game type invalid. ErrInvalidGameType = errors.New("invalid game type") // ErrInvalidGameVsMode - Game mode invalid. ErrInvalidGameVsMode = errors.New("invalid game mode") // ErrInvalidGameDirection - Game direction invalid. ErrInvalidGameDirection = errors.New("invalid game direction") // ErrUnableToBroadcastUpdate - Unable to broadcast update. ErrUnableToBroadcastUpdate = errors.New("unable to broadcast update") // ErrTournamentNotFound - Tournament not found. ErrTournamentNotFound = errors.New("tournament not found") // ErrInvalidTournamentID - Invalid tournament id. ErrInvalidTournamentID = errors.New("invalid tournament id") // ErrInvalidTournamentDetails - Invalid tournament details. ErrInvalidTournamentDetails = errors.New("invalid tournament details") // ErrInvalidTableNumber - Invalid table number. ErrInvalidTableNumber = errors.New("invalid table number") // ErrRemoveOnlyTable - Cannot remove only table. ErrRemoveOnlyTable = errors.New("cannot remove only table") )
var VersionLatest = "latest"
VersionLatest is the latest version for the API. We should only be using this for development.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Host string `json:"host"` Port string `json:"port"` PublicDir string `json:"public_dir"` Version *Version `json:"version"` }
Config is the configuration for the API package.
type CountResp ¶
type CountResp struct {
Count int64 `json:"count"`
}
CountResp is a count of entities for the endpoint.
type ErrorResp ¶
type ErrorResp struct {
Err string `json:"error"`
}
ErrorResp is an error response.
type GameFargoHotHandicapPatchBody ¶
type GameFargoHotHandicapPatchBody struct {
UseFargoHotHandicap bool `json:"useFargoHotHandicap"`
}
GameFargoHotHandicapPatchBody is the incoming body on a patch request for updating the fargo hot handicap.
type GameFargoHotHandicapPatchResp ¶
type GameFargoHotHandicapPatchResp struct {
UseFargoHotHandicap bool `json:"useFargoHotHandicap"`
}
GameFargoHotHandicapPatchResp is the response containing the new fargo hot handicap setting.
type GamePlayersDeleteBody ¶
type GamePlayersDeleteBody struct {
PlayerNum int `json:"playerNum"`
}
GamePlayersDeleteBody is the incoming body on a delete request for unsetting the specified player num.
type GamePlayersFlagPatchBody ¶
type GamePlayersFlagPatchBody struct { PlayerNum int `json:"playerNum"` FlagID int `json:"flagID"` }
GamePlayersFlagPatchBody is the incoming body on a patch request for updating the player num to a specified flag id.
type GamePlayersNamePatchBody ¶
GamePlayersNamePatchBody is the incoming body on a patch request for updating the player name for the specified player num.
type GamePlayersPatchBody ¶
type GamePlayersPatchBody struct { PlayerNum int `json:"playerNum"` PlayerID int `json:"playerID"` }
GamePlayersPatchBody is the incoming body on a patch request for updating the player num to a specified player id.
type GameRaceToPatchBody ¶
type GameRaceToPatchBody struct {
Direction string `json:"direction"`
}
GameRaceToPatchBody is the incoming body on a patch request for updating the game race to.
type GameRaceToResp ¶
type GameRaceToResp struct { RaceTo int `json:"raceTo"` UseFargoHotHandicap bool `json:"useFargoHotHandicap"` }
GameRaceToResp is a reponse containing the game race to.
type GameScorePatchBody ¶
type GameScorePatchBody struct { PlayerNum int `json:"playerNum"` Direction string `json:"direction"` }
GameScorePatchBody is the incoming body on a patch request for updating the game score for the specified player.
type GameScoreResp ¶
GameScoreResp is a reponse containing the game score.
type GameTeamsPatchBody ¶
GameTeamsPatchBody is the incoming body on a patch request for updating the team for the specified team number.
type GameTypePatchBody ¶
GameTypePatchBody is the incoming body on a patch request for updating the game type.
type GameTypeResp ¶
GameTypeResp is a reponse containing the game type.
type GameVsModePatchBody ¶
type GameVsModePatchBody struct {
VsMode models.GameVsMode `json:"vsMode"`
}
GameVsModePatchBody is the incoming body on a patch request for updating the game vs mode.
type GameVsModeResp ¶
type GameVsModeResp struct {
VsMode models.GameVsMode `json:"vsMode"`
}
GameVsModeResp is a reponse containing the game type.
type OverlayToggleFargoResp ¶
type OverlayToggleFargoResp struct {
ShowFargo bool `json:"showFargo"`
}
OverlayToggleFargoResp is the response from toggling fargo ratings on the overlay.
type OverlayToggleFlagsResp ¶
type OverlayToggleFlagsResp struct {
ShowFlags bool `json:"showFlags"`
}
OverlayToggleFlagsResp is the response from toggling flags on the overlay.
type OverlayToggleResp ¶
type OverlayToggleResp struct {
Hidden bool `json:"hidden"`
}
OverlayToggleResp is the response from toggling the overlay.
type OverlayToggleScoreResp ¶
type OverlayToggleScoreResp struct {
ShowScore bool `json:"showScore"`
}
OverlayToggleScoreResp is the response from toggling the player scores on the overlay.
type PlayersPatchBody ¶
type PlayersPatchBody struct { Name string `json:"name"` FlagID uint `json:"flag_id"` FargoObservableID uint `json:"fargo_observable_id"` FargoID uint `json:"fargo_id"` FargoRating uint `json:"fargo_rating"` }
PlayersPatchBody is an incoming body on a PATCH request for updating a player.
type PlayersPostBody ¶
type PlayersPostBody struct { Name string `json:"name"` FlagID uint `json:"flag_id"` FargoObservableID uint `json:"fargo_observable_id"` FargoID uint `json:"fargo_id"` FargoRating uint `json:"fargo_rating"` }
PlayersPostBody is an incoming body on a POST request for creating a player.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an api server.
func NewServer ¶
func NewServer(config *Config, db *gorm.DB, overlay *overlay.Overlay, telestrator *telestrator.Telestrator, tables map[int]*state.State, challonge *challonge.Challonge) *Server
NewServer returns a new api server.
func (*Server) AddRouteToAllVersions ¶
AddRouteToAllVersions adds the route to all versions of the api.
func (*Server) AddRouteToVersion ¶
AddRouteToVersion adds a route to a versioned subrouter.
func (*Server) AddVersion ¶
AddVersion adds a new sub router with version prefix
func (*Server) HandleOptions ¶
func (server *Server) HandleOptions(w http.ResponseWriter, r *http.Request)
HandleOptions returns a 200 status code for preflight checks.
func (*Server) InitRoutes ¶
func (server *Server) InitRoutes()
InitRoutes adds all routes to the api.
func (*Server) SetupResponse ¶
func (server *Server) SetupResponse(w http.ResponseWriter, r *http.Request)
SetupResponse adds CORS headers to an API response.
type TournamentLoadBody ¶
type TournamentLoadBody struct { ID int `json:"id"` Settings TournamentLoadBodySettings `json:"settings"` }
type TournamentLoadBodySettings ¶
type TournamentLoadBodySettings struct { MaxTables int `json:"max_tables"` GameType models.GameType `json:"game_type"` ShowOverlay bool `json:"show_overlay"` ShowFlags bool `json:"show_flags"` ShowFargo bool `json:"show_fargo"` ShowScore bool `json:"show_score"` IsHandicapped bool `json:"is_handicapped"` ASideRaceTo int `json:"a_side_race_to"` BSideRaceTo int `json:"b_side_race_to"` }