abcserver

package
v3.0.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2018 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Redirect

func Redirect(cfg abcconfig.ServerConfig, logger *zap.Logger)

Redirect listens on the non-https port, and redirects all requests to https

func StartServer

func StartServer(cfg abcconfig.ServerConfig, router http.Handler, logger *zap.Logger) error

StartServer starts the web server on the specified port, and can be gracefully shut down by sending an os.Interrupt signal to the server. This is a blocking call.

Types

type MethodNotAllowed

type MethodNotAllowed struct {
	Templates MethodNotAllowedTemplates
}

MethodNotAllowed holds the state for the MethodNotAllowed handler

func NewMethodNotAllowedHandler

func NewMethodNotAllowedHandler() *MethodNotAllowed

NewMethodNotAllowedHandler creates a new handler

func (*MethodNotAllowed) Handler

func (m *MethodNotAllowed) Handler(render abcrender.Renderer) http.HandlerFunc

Handler is a wrapper around the MethodNotAllowed handler. The MethodNotAllowed handler is called when someone attempts an operation against a route that does not support that operation, for example attempting a POST against a route that only supports a GET.

type MethodNotAllowedTemplates

type MethodNotAllowedTemplates struct {
	MethodNotAllowed string
}

MethodNotAllowedTemplates for specific errors

type NotFound

type NotFound struct {
	Templates NotFoundTemplates
	// The manifest file mappings
	AssetsManifest map[string]string
}

NotFound holds the state for the NotFound handler

func NewNotFoundHandler

func NewNotFoundHandler(manifest map[string]string) *NotFound

NewNotFoundHandler creates a new handler

func (*NotFound) Handler

Handler is a wrapper that creates a new NotFound handler. The NotFound handler is called if the requested route or asset cannot be found. Since we cannot use Chi's FileServer because it does directory listings we have to serve static assets (public folder) from the NotFound handler.

The NotFound handler works for assets in both /public and /public/assets

The NotFound handler checks if the path has "/assets", and if found will attempt to retrieve the asset name from the compiled assets manifest file if in production mode. In development mode it will ignore manifest and attempt to serve the asset directly.

For paths that aren't "/assets/X" it will attempt to serve the asset directly, if it exists.

Assets that cannot be found will return 404.

type NotFoundTemplates

type NotFoundTemplates struct {
	NotFound            string
	InternalServerError string
}

NotFoundTemplates for specific errors

Jump to

Keyboard shortcuts

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