Documentation ¶
Overview ¶
Package http provides utilities for running a http server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶ added in v0.2.0
An Option modifies the behaviour of a `Server`.
func WithBaseContext ¶ added in v0.2.0
WithBaseContext sets the `context.Context` that will server as base context for incoming requests.
func WithLogger ¶ added in v0.2.0
WithLogger sets the logger used for the underlying `http.Server`. The supplied logger will be named "http" and log at error level.
func WithShutdownTimeout ¶ added in v0.2.0
WithShutdownTimeout sets the timeout of the graceful shutdown.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements a http server which handles request using the configured `http.Handler`. It provides graceful shutdown capabilities using `context.Context` propagation.
func NewServer ¶
NewServer creates a new http server listening on the configured address and handling requests using the configured `http.Handler`. An error is returned if the address the server should listen on is already in use.
func (*Server) ListenAddr ¶
ListenAddr returns the address the http server is listening on.
func (*Server) ListenError ¶
ListenError returns the receive-only channel which signals errors during http server startup.
func (*Server) Run ¶
Run starts the http server in a separate goroutine and pushes errors into the errors channel. This method is non-blocking. Use the `ListenError()` method to listen for errors which occure during startup and handle them accordingly.