server

package
v0.33.10 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Config *config.Config

	Handler http.Handler
	Routes  []WithRoutes
}

Config defines a Server's configuration settings.

type Server

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

Server is our HTTP server implementation.

func NewServer

func NewServer(c *Config) (*Server, error)

NewServer constructs a server from the provided parameters.

func (*Server) AddContext

func (s *Server) AddContext(parent context.Context, next http.Handler) http.Handler

AddContext adds the associated server context with cancel to the the provided httprouter.Handle. When the handler is done, the per Request context is cancelled.

func (*Server) AddRoutes

func (s *Server) AddRoutes(ctx context.Context, router *mux.Router)

AddRoutes add the associated Servers URL routes to the provided router with the provided context.Context.

func (*Server) HealthCheckHandler

func (s *Server) HealthCheckHandler(rw http.ResponseWriter, req *http.Request)

HealthCheckHandler a http handler return 200 OK when server health is fine.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context) error

Serve starts all the accociated servers resources and listeners and blocks forever until signals or error occurs. Returns error and gracefully stops all HTTP listeners before return.

type WithRoutes

type WithRoutes interface {
	AddRoutes(ctx context.Context, router *mux.Router)
}

WithRoutes provide http routing within a context.

Jump to

Keyboard shortcuts

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