server

package
v0.56.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: Apache-2.0 Imports: 12 Imported by: 4 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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