server

package
v0.0.0-...-b350d92 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvMetricsEnabled = "METRICS_ENABLED"
	EnvServerHost     = "SERVER_HOST"
	EnvServerPort     = "SERVER_PORT"
)

Environment Vars

Variables

View Source
var ErrShutdownFailed = errors.New("ErrShutdownFailed: Failed to shutdown http server. Is the server running?")

ErrShutdownFailed is the error returned when the Server failed to shutdown gracefully

Functions

This section is empty.

Types

type Config

type Config struct {
	BasePath       string
	MetricsEnabled bool
	Name           string
	Port           int
}

Config exposes Server configuration options

func NewConfig

func NewConfig() *Config

NewConfig constructs a new *server.Config instance with defaults

type Resource

type Resource interface {
	Path() string
	Routes() http.Handler
}

Resource encapsulates a logical collection of handlers to be bound to a HTTP Server

type Server

type Server interface {
	RegisterMiddleware(middleware ...func(http.Handler) http.Handler)
	RegisterResource(resource Resource)
	Run() error
	Shutdown() error
}

Server encapsulates a HTTP Server lifecycle

func New

func New(cfg *Config) Server

New is a constructor func which creates and returns a new Server instance

Jump to

Keyboard shortcuts

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