Documentation ¶
Index ¶
- func ListenAndServe(ctx context.Context, addr string, srv *http.Server) error
- func ListenAndServeMonitoring(ctx context.Context, addr string, healthHandler http.Handler) error
- func ListenAndServePprof(ctx context.Context, addr string) error
- func New(cfg *Config) (*http.Server, error)
- type Config
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶
ListenAndServe serves an http server over TCP
func ListenAndServeMonitoring ¶
ListenAndServeMonitoring starts up an HTTP server serving /metrics and /health.
When the context is canceled, the server will be gracefully shutdown.
func ListenAndServePprof ¶
ListenAndServePprof starts a pprof server
func New ¶
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 ¶
Click to show internal directories.
Click to hide internal directories.