server

package
v0.0.0-...-135d0e9 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package server provides a REST API for playing games.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Address string
	Hangman HangmanConfig
}

Config defines the main settings of the game server

func LoadConfig

func LoadConfig(paths ...string) (*Config, error)

LoadConfig loads a config from a local file or url

type HangmanConfig

type HangmanConfig struct {
	Words []string
	Turns int
	// contains filtered or unexported fields
}

HangmanConfig defines the main settings for the Hangman game

type Server

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

Server is an instance of a REST gameserver.

func NewServer

func NewServer(cfg *Config) *Server

NewServer creates a new instance of Server with default in-memory storage,

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts the server. This function blocks until either Shutdown is called or the process is terminated.

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown attempts a graceful shutdown of the server, timing out after 5 seconds.

func (*Server) WithStore

func (s *Server) WithStore(store store.Store) *Server

WithStore overrides the default in-memory storage with a client-specified storage.

Jump to

Keyboard shortcuts

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