routes

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default rows used for creating a new game.
	DefaultRows = 15
	// Default columns used for creating a new game.
	DefaultColumns = 10
	// Default mines used for creating a new game.
	DefaultMines = 30
)

Variables

View Source
var Collection string

Instance variable to store the DB Collection name.

View Source
var Database string

Instance variable to store the Database name.

Functions

func GetUsernamesFromGames added in v0.0.4

func GetUsernamesFromGames(games []objects.Game) []string

Creates a list of usernames from the list of games.

func GetUsers

func GetUsers(usernames []string, headers http.Header) ([]objects.User, error)

Method to interact with the users client for getting the users from games.

func HandlerGetUsers added in v0.0.4

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

Handler for getting the leaderboard based on configuration. Creates a list of users who has games saved for the selected configuration and returns the list in decreasing order of rating.

func HandlerNewGame added in v0.0.4

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

Handler for creating a new game. Row, Column and Mine count can be passed as query parameters. If any of the count is not available, defaults will be used.

func HandlerSaveGame added in v0.0.4

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

Handler for saving a game to the kafka topic. The consumer of the topic saves the game to the DB. The consumer updates the rating of the user in the DB.

func Print2D added in v0.0.4

func Print2D(arr [][]string)

Prints a 2d array as a matrix.

func Routes

func Routes() *http.ServeMux

Add handlers and interceptors to the endpoints.

Types

This section is empty.

Jump to

Keyboard shortcuts

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