server

package
v0.0.0-...-b6702c2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2018 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package server provides a HTTP listener for handling requests from either a game server or any form of interface to the data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App stores and controls program state

func Initialise

func Initialise(config *Config) (app *App, err error)

Initialise performs all the necessary actions to bootstrap the application into a runnable state ready for starting with app.Start

func (*App) Authenticator

func (app *App) Authenticator(next http.Handler) http.Handler

Authenticator is a middleware layer for requests that require authentication

func (*App) Start

func (app *App) Start() (err error)

Start fires up the HTTP server and blocks until failure

func (*App) Stop

func (app *App) Stop() (err error)

Stop gracefully shuts down the application

type Config

type Config struct {
	Temporary bool   `default:"true"`
	Bind      string `default:"0.0.0.0:7788"`
	Auth      string `default:"cunning_fox"`
	MongoHost string `split_words:"true" required:"false"`
	MongoPort string `split_words:"true" required:"false"`
	MongoName string `split_words:"true" required:"false"`
	MongoUser string `split_words:"true" required:"false"`
	MongoPass string `split_words:"true" required:"false"`
}

Config stores static configuration

type EndpointHandler

type EndpointHandler func(r io.Reader, query url.Values) (types.Status, error)

EndpointHandler wraps a HTTP handler function with app-specific args/returns

func (EndpointHandler) ServeHTTP

func (f EndpointHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the necessary chaining functionality for HTTP middleware

type Route

type Route struct {
	Name    string      `json:"name"`
	Method  string      `json:"method"`
	Path    string      `json:"path"`
	Accepts interface{} `json:"accepts"`
	Returns interface{} `json:"returns"`
	// contains filtered or unexported fields
}

Route represents an API route and its associated handler function

Jump to

Keyboard shortcuts

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