server

package
v0.0.0-...-3462b3d Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: BSD-3-Clause, MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	*config.Config
	*mux.Router
	*http.Server
	// contains filtered or unexported fields
}

Server represents the running server with embedded *http.Server, *mux.Router, zerolog.Logger instances manages the configurations, starting, stopping and routing of HTTP server instance

func New

func New(c *config.Config) *Server

New configures and returns a server instance struct.

func (*Server) AcceptConnections

func (s *Server) AcceptConnections() error

AcceptConnections listens on the configured address and ports for http traffic. Simultaneously listens for incoming os signals, will return on either a server error or a shutdown signal

func (*Server) LivenessCheck

func (s *Server) LivenessCheck()

LivenessCheck retrieves home page to verify the liveness of the server, then notifies the systemd daemon to pass the check.

func (*Server) OpenListener

func (s *Server) OpenListener() (net.Listener, error)

OpenListener returns a listener for the server to receive traffic on, or err

func (*Server) RecoverHandler

func (s *Server) RecoverHandler(next http.Handler) http.Handler

RecoverHandler catches panics in downstream handlers, sends an error to gracefully alert the client

func (*Server) RegisterHandlers

func (s *Server) RegisterHandlers()

RegisterHandlers attemtps to prepare and register the specified routes with the given middlewware on the server instance.

func (*Server) ServeStatic

func (s *Server) ServeStatic(key string) http.HandlerFunc

ServeStatic prepares and returns a http.Handler serving a single file

func (*Server) WrapRoute

func (s *Server) WrapRoute(h http.HandlerFunc) http.HandlerFunc

WrapRoute composes endpoints by wrapping destination handler with handler pipeline providing tracing with aws x-ray, injecting logging middleware with request details into the context, and error recovery middleware, and gzipping the response

Jump to

Keyboard shortcuts

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