Documentation ¶
Index ¶
Constants ¶
const ( // DefaultShutdownTimeout is the default shutdown timeout. DefaultShutdownTimeout = 10 * time.Second // DefaultReadHeaderTimeout is the default read header timeout. DefaultReadHeaderTimeout = 30 * time.Second // DefaultIdleTimeout is the amount of time an HTTP/2 connection can be idle. DefaultIdleTimeout = 3 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run( ctx context.Context, logger *zap.Logger, listener net.Listener, handler http.Handler, options ...RunOption, ) error
Run will start a HTTP server listening on the provided listener and serving the provided handler. This call is blocking and the run is cancelled when the input context is cancelled, the listener is closed upon return.
The Run function can be configured further by passing a variety of options.
Types ¶
type RunOption ¶
type RunOption func(*runner)
RunOption is an option for a new Run.
func RunWithReadHeaderTimeout ¶
RunWithReadHeaderTimeout returns a new RunOption that uses the given read header timeout.
The default is to use DefaultReadHeaderTimeout. If readHeaderTimeout is 0, no read header timeout will be used.
func RunWithShutdownTimeout ¶
RunWithShutdownTimeout returns a new RunOption that uses the given shutdown timeout.
The default is to use DefaultShutdownTimeout. If shutdownTimeout is 0, no graceful shutdown will be performed.
func RunWithTLSConfig ¶
RunWithTLSConfig returns a new RunOption that uses the given tls.Config.
The default is to use no TLS.
func RunWithWalkFunc ¶
func RunWithWalkFunc(walkFunc chi.WalkFunc) RunOption
RunWithWalkFunc returns a new RunOption that runs chi.Walk to walk the handler after all middlewares and routes have been mounted, but before the server is started. The walkFunc will only be called if the handler passed to Run is a chi.Routes.