http

package
v2.8.3 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(ctx context.Context, addr string, srv *http.Server) error

ListenAndServe serves an http server over TCP

func ListenAndServePprof

func ListenAndServePprof(ctx context.Context, addr string) error

ListenAndServePprof starts a pprof server

func New

func New(cfg *Config) (*http.Server, error)

New creates a new http server

Example:

srv, _ := server.New(&server.Config{
 Addr: ":8080",
 Handler: http.DefaultServeMux,
 Options: []server.Option{
   server.WithLogging("my-server"),
   server.WithMetrics("my-server"),
   server.WithRecovery(),
   server.WithTracing("opentracing-server:6831", "my-server"),
 }
})

srv.ListenAndServe(context.Background())

Types

type Config

type Config struct {
	Addr    string
	Handler http.Handler
	Options []Option
}

Config contains the http servers config options

type Option

type Option interface {
	WrapHandler(handler http.Handler) http.Handler
}

Option is the interface for all server options defined in this package

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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