server

package
v0.0.0-...-015e340 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	DecodeToken(token string) (*models.User, error)
	NewTokenForUser(user *models.User) (string, error)
}

Authenticator is the interface to interact with the Authenticator (DB, OIDC provider, etc.)

type FranchiseModel

type FranchiseModel interface {
	Insert(franchise *models.Franchise) (*models.Franchise, error)
	All(userID string) ([]*models.Franchise, error)
}

FranchiseModel is the interface to interact with the Franchise provider (DB, service, etc.)

type GameModel

type GameModel interface {
	AllForUser(userID string) ([]*models.Game, error)
	Get(id string) (*models.Game, error)
	Insert(game *models.Game) (*models.Game, error)
	DeleteGame(userID, gameID string) error
	ChangeGameStatus(userID, gameID string, status models.Status) error
	ChangeGameProgress(userID, gameID string, progress *models.GameProgress) error
}

GameModel is the interface to interact with the Games provider (DB, service, etc.)

type GamePatchRequest

type GamePatchRequest struct {
	Status string `json:"status"`
}

type Options

Options is the struct used to construct a server

type Server

Server is the struct that holds all the dependencies needed to run the application

func New

func New(opts *Options) (*Server, error)

New returns a new Server, based on opts. It also validates the arguments and can return an error if it receives options that are not right.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implement the http.Handler inteface

func (*Server) Start

func (s *Server) Start(port int) error

Start starts the server listenning on the given port

type UserGamesModel

type UserGamesModel interface {
	LinkGameToUser(userID, gameID string, progress *models.GameProgress) error
	ChangeGameStatus(userID, userGameID string, status models.Status) error
	ChangeGameProgress(userID, userGameID string, progress *models.GameProgress) error
	GetAvailableGamesFor(userID string) ([]*models.Game, error)
	DeleteUserGame(userGameID string) error
}

UserGamesModel is the interface to interact with the Users-Games relationship provider (DB, service, etc.)

type UserModel

type UserModel interface {
	Insert(user *models.User) (*models.User, error)
	Authenticate(email, password string) (*models.User, error)
	AssociateTokenWithUser(userID, token string) error
	InvalidateToken(userID, token string) error
	GetUserByToken(token string) (*models.User, error)
}

UserModel is the interface to interact with the User provider (DB, service, etc.)

Jump to

Keyboard shortcuts

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