api

package
v0.0.0-...-7c548eb Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

API for existing games.

API for session management.

Helper functions for API communication and game setup.

Structs for API communication are defined here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteSessions

func DeleteSessions(w http.ResponseWriter, r *http.Request)

Deletes an ongoing game

func GetGame

func GetGame(w http.ResponseWriter, r *http.Request)

Get the state of a game

func GetSessions

func GetSessions(w http.ResponseWriter, r *http.Request)

Displays all existing games

func PostSessions

func PostSessions(w http.ResponseWriter, r *http.Request)

Creates a new game

func PutGame

func PutGame(w http.ResponseWriter, r *http.Request)

Apply a move

func PutSessions

func PutSessions(w http.ResponseWriter, r *http.Request)

Entries a games

func UpdateTurn

func UpdateTurn(w http.ResponseWriter, r *http.Request)

Endpoint to update the player turn for testing purposes

Types

type GameNameAndID

type GameNameAndID struct {
	Name    string `json:"name"`
	BoardID int32  `json:"boardid"`
}

type ReqDeleteSessions

type ReqDeleteSessions struct {
	BoardID  int32  `json:"boardid"`
	Password string `json:"password"`
}

Delete an ongoing game

type ReqGetGame

type ReqGetGame struct {
	Moveidx  int32  `schema:"moveidx"`
	BoardID  int32  `schema:"boardid"`
	Password string `schema:"password"`
	Color    string `schema:"color"`
	Token    string `schema:"token"`
	Statereq bool   `schema:"statereq"`
	Turnreq  bool   `schema:"turnreq"`
}

Get game data

type ReqPostSessions

type ReqPostSessions struct {
	Name string `json:"name"`
}

Create new game

type ReqPutGame

type ReqPutGame struct {
	BoardID  int32  `json:"boardid"`
	Password string `json:"password"`
	Color    string `json:"color"`
	Token    string `json:"token"`
	Move     string `json:"move,omitempty"`
	Forfeit  bool   `json:"forfeit,omitempty"`
}

Apply move

type ReqPutSessions

type ReqPutSessions struct {
	BoardID  int32  `json:"boardid"`
	Password string `json:"password"`
	Color    string `json:"color"`
}

Entry a game

type RespGetSessions

type RespGetSessions struct {
	Games []GameNameAndID `json:"games"`
}

Get all sessions

type RespPostSessions

type RespPostSessions struct {
	BoardID  int32  `json:"boardid"`
	Password string `json:"password"`
}

type RespPutSessions

type RespPutSessions struct {
	Token string `json:"token"`
}

Jump to

Keyboard shortcuts

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