controllers

package
v0.0.0-...-2cd49de Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GameController

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

Struct GameController is an API controller for the Games collection.

func NewGameController

func NewGameController(db *gorm.DB) *GameController

Function NewGameController is the constructor for the GameController struct. It injects the database provided and returns a reference to the newly created struct.

func (*GameController) All

func (gc *GameController) All(c *gin.Context)

Method All is responsible for handling the GET /games endpoint. It returns all games, optionally filtering by user_id.

func (*GameController) Create

func (gc *GameController) Create(c *gin.Context)

Method Create is responsible for handling the POST /games endpoint. It performs input sanitisation and saves the new game to the database. The generated game_id is returned in the response.

func (*GameController) Delete

func (gc *GameController) Delete(c *gin.Context)

Method Delete is responsible for handling the DELETE /games/:game_id endpoint.It deletes the game (and its players) from the database.

func (*GameController) One

func (gc *GameController) One(c *gin.Context)

Method One is responsible for handling the GET /games/:game_id endpoint. It returns the user indentified by the id provided.

func (*GameController) Update

func (gc *GameController) Update(c *gin.Context)

Method Update is responsible for handling the PUT /games/:game_id endpoint. It performs input sanitisation and updates the game by the values provided.

type StatController

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

Struct StatController is an API controller for the Stats collection.

func NewStatController

func NewStatController(db *gorm.DB) *StatController

Function NewStatController is the constructor for the StatController struct. It injects the database provided and returns a refrerence to the newly created struct.

func (*StatController) All

func (sc *StatController) All(c *gin.Context)

Method All is responsible for handling the GET /stats endpoint. It calculates all relevant statistics for the provided user_id. Calculated statistics are returned in the response.

type UserController

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

Struct UserController is an API Controller for the Users collection.

func NewUserController

func NewUserController(db *gorm.DB) *UserController

Function NewUserController is the constructor for the UserController struct. It injects the database provided and returns a reference to the newly created struct.

func (*UserController) All

func (uc *UserController) All(c *gin.Context)

Method All is responsible for handling the GET /users endpoint. It returns all users, optionally filtering by first or last name.

func (*UserController) Create

func (uc *UserController) Create(c *gin.Context)

Method Create is responsible for handling the POST /users endpoint. It performs input sanitisation and saves the new user to the database. The generated user_id is returned in the response.

func (*UserController) Delete

func (uc *UserController) Delete(c *gin.Context)

Method Delete is responsible for handling the DELETE /users/:user_id endpoint. It deletes the user from the database.

func (*UserController) One

func (uc *UserController) One(c *gin.Context)

Method One is responsible for handling the GET /users/:user_id endpoint. It returns the user identified by the id provided.

func (*UserController) Update

func (uc *UserController) Update(c *gin.Context)

Method Update is responsible for handling the PUT /users/:user_id endpoint. It performs input sanitisation and updates the user by the values provided.

Jump to

Keyboard shortcuts

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