httpServer

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: MIT Imports: 10 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 {
	// contains filtered or unexported fields
}

Server provides a gracefolly-stoppable http server implementation. It is safe for concurrent use in goroutines

func New

func New(port string) (*Server, error)

New creates a new server listening on the provided address that responds to the http.Handler. It starts the listener, but does not start the server. If an empty port is given, the server randomly chooses one.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(ctx context.Context, srv *http.Server) error

ServeHTTP starts the server and blocks until the provided context is closed. When the provided context is closed, the server is gracefully stopped with a timeout of 5 seconds.

Once a server has been stopped, it is NOT safe for reuse.

func (*Server) ServeHTTPWithHandler

func (s *Server) ServeHTTPWithHandler(ctx context.Context, handler http.Handler) error

func (*Server) ServeHTTPWithObservabilityHandler

func (s *Server) ServeHTTPWithObservabilityHandler(ctx context.Context, handler http.Handler) error

ServeHTTPHandler is a convenience wrapper around ServeHTTP. It creates an HTTP server using the provided handler, wrapped in OpenCensus for observability.

Jump to

Keyboard shortcuts

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