Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartServer ¶
func StartServer(cfg abcconfig.ServerConfig, router http.Handler, logger *zap.Logger, kill chan struct{}) 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 ¶
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 ¶
NewNotFoundHandler creates a new handler
func (*NotFound) Handler ¶
func (n *NotFound) Handler(cfg abcconfig.ServerConfig, render abcrender.Renderer) http.HandlerFunc
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 ¶
NotFoundTemplates for specific errors
type ServerErrLogger ¶
type ServerErrLogger struct {
// contains filtered or unexported fields
}
ServerErrLogger allows us to use the zap.Logger as our http.Server ErrorLog