Documentation ¶
Index ¶
- Variables
- type ActiveGamesResponse
- type ApiNotFoundResponse
- type AuthChallengeRequest
- type AuthChallengeResponse
- type AuthResponseRequest
- type AuthResponseResponse
- type GetGameResponse
- type Handler
- type MoveRequest
- type MoveResponse
- type NewGameRequest
- type NewGameResponse
- type NewSessionResponse
- type NextMoveResponse
- type Provider
- type Request
- type Response
- type WhoAmIResponse
Constants ¶
This section is empty.
Variables ¶
var ActiveGamesHandler activeGamesHandler
var ApiNotFoundHandler apiNotFoundHandler
var AuthChallengeHandler authChallengeHandler
var AuthResponseHandler authResponseHandler
var ( // ErrParser is thrown when a request object is of the wrong type ErrParser error = errParse{} )
var GetGameHandler getGameHandler
var HomeHandler homeHandler
var MoveHandler moveHandler
var NewGameHandler newGameHandler
var NewSessionHandler newSessionHandler
var NextMoveHandler nextMoveHandler
var WhoAmIHandler whoAmIHandler
Functions ¶
This section is empty.
Types ¶
type ActiveGamesResponse ¶
type ActiveGamesResponse struct {
GameIDs []string `json:"gameid"`
}
The ActiveGamesResponse wraps a ActiveGamesHandler API response
func (ActiveGamesResponse) FlaggedAsResponse ¶
func (ActiveGamesResponse) FlaggedAsResponse()
type ApiNotFoundResponse ¶
type ApiNotFoundResponse struct { }
The ApiNotFoundResponse wraps a ApiNotFoundHandler API response
func (ApiNotFoundResponse) FlaggedAsResponse ¶
func (ApiNotFoundResponse) FlaggedAsResponse()
type AuthChallengeRequest ¶
type AuthChallengeRequest struct {
Username string `json:"username"`
}
func (AuthChallengeRequest) FlaggedAsRequest ¶
func (AuthChallengeRequest) FlaggedAsRequest()
type AuthChallengeResponse ¶
type AuthChallengeResponse struct {
Nonce string `json:"nonce"`
}
The AuthChallengeResponse wraps a AuthChallengeHandler API response
func (AuthChallengeResponse) FlaggedAsResponse ¶
func (AuthChallengeResponse) FlaggedAsResponse()
type AuthResponseRequest ¶
type AuthResponseRequest struct { Username string `json:"username"` Nonce string `json:"nonce"` Response string `json:"response"` }
func (AuthResponseRequest) FlaggedAsRequest ¶
func (AuthResponseRequest) FlaggedAsRequest()
type AuthResponseResponse ¶
type AuthResponseResponse struct { }
The AuthResponseResponse wraps a AuthResponseHandler API response
func (AuthResponseResponse) FlaggedAsResponse ¶
func (AuthResponseResponse) FlaggedAsResponse()
type GetGameResponse ¶
The GetGameResponse wraps a GetGameHandler API response
func (GetGameResponse) FlaggedAsResponse ¶
func (GetGameResponse) FlaggedAsResponse()
type Handler ¶
type Handler interface { // DecodeRequest turns a HTTP request into a domain-specific request type DecodeRequest(*http.Request) (Request, error) // A RequestHandler is a monadic definition of a request handler. The inputs // are the current state of the world, and a handler-specific request type, // and the output is the new state of the world (which may or may not be the // same), a handler-specific response type, and/or an error. HandleRequest(Provider, Request) (Response, error) }
A Handler handles requests
type MoveRequest ¶
func (MoveRequest) FlaggedAsRequest ¶
func (MoveRequest) FlaggedAsRequest()
type MoveResponse ¶
type MoveResponse struct { }
The MoveResponse wraps a MoveHandler API response
func (MoveResponse) FlaggedAsResponse ¶
func (MoveResponse) FlaggedAsResponse()
type NewGameRequest ¶
type NewGameRequest struct { RuleSet string `json:"ruleset"` PlayerNames []string `json:"players"` }
func (NewGameRequest) FlaggedAsRequest ¶
func (NewGameRequest) FlaggedAsRequest()
type NewGameResponse ¶
type NewGameResponse struct {
GameID string `json:"gameid"`
}
The NewGameResponse wraps a NewGameHandler API response
func (NewGameResponse) FlaggedAsResponse ¶
func (NewGameResponse) FlaggedAsResponse()
type NewSessionResponse ¶
type NewSessionResponse struct {
SessionID string `json:"session_id"`
}
The NewSessionResponse wraps a NewSessionHandler API response
func (NewSessionResponse) FlaggedAsResponse ¶
func (NewSessionResponse) FlaggedAsResponse()
type NextMoveResponse ¶
type NextMoveResponse struct {
Move *chesseract.Move `json:"move,omitempty"`
}
The NextMoveResponse wraps a NextMoveHandler API response
func (NextMoveResponse) FlaggedAsResponse ¶
func (NextMoveResponse) FlaggedAsResponse()
type Provider ¶
type Provider interface { // NewSession generates a new empty session, and returns a string // representation of its ID, to be communicated to the client. NewSession() (string, error) // Player returns the player associated with this session Player() (game.Player, error) // SetPlayer assigns this player to this session SetPlayer(game.Player) error // LookupPlayer finds the profile in the database, if it exists LookupPlayer(string) (game.Player, bool, error) // NewNonce generates a new auth challenge for this player NewNonce(string) (string, error) // ValidateNonce checks if a nonce is valid for this player ValidateNonce(playerName string, nonce string) (bool, error) // ActiveGames returns the list of active game ID's in which the player is involved ActiveGames() ([]string, error) // GetGame retrieves a game by its ID GetGame(gameid string) (*game.Game, error) // NewGame creates a new game with the specified players, and returns its game ID NewGame(ruleset string, playerNames []string) (string, error) // Game returns the game object of the currently active game session, if applicable Game() (*game.Game, error) // SubmitMove appends a move to the currently active game SubmitMove(chesseract.Move) error }
The Provider is the Handlers' interface to the data backend. It is assumed that the Provider has performed all necessary context wrangling and cookie consuming
type WhoAmIResponse ¶
The WhoAmIResponse wraps a WhoAmIHandler API response
func (WhoAmIResponse) FlaggedAsResponse ¶
func (WhoAmIResponse) FlaggedAsResponse()