server

package
v0.0.0-...-07636e0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBasicMiddleware

func AddBasicMiddleware(c *Config)

AddBasicMiddleware is a helper function that augments the passed in Config with some basic middleware components

func BindLoggerMiddleware

func BindLoggerMiddleware(requestIDKey interface{}) func(http.Handler) http.Handler

BindLoggerMiddleware returns a LoggerMiddleware bound to the passed in requestIdKey, thereby decoupling it from middleware.RequestID

func NewRouter

func NewRouter(c *Config) *chi.Mux

NewRouter creates a new router with the provided config

func Serve

func Serve(router *chi.Mux, port int, tls *TLSConfig)

Serve starts a web server by binding it to a socket and setting up the shutdown signals

Types

type Config

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

Config is the immutable Config file that will be used to construct a server

func EmptyConfig

func EmptyConfig() *Config

EmptyConfig gives you a new empty Config

func (*Config) Middleware

func (c *Config) Middleware(m func(http.Handler) http.Handler)

Middleware adds a middleware to the list

func (*Config) NotFound

func (c *Config) NotFound(handler http.HandlerFunc)

NotFound sets the handler for when a resource is not found

func (*Config) Route

func (c *Config) Route(method string, path string, handler http.HandlerFunc)

Route allows you to set (or override) an existing route by the HTTP method

type TLSConfig

type TLSConfig struct {
	CertificateFile string `toml:"certificate-file" valid:"required"`
	PrivateKeyFile  string `toml:"private-key-file" valid:"required"`
}

TLSConfig specifies the TLS portion of a config

Jump to

Keyboard shortcuts

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