Documentation ¶
Index ¶
- Constants
- type HTTPHandlerMapperOption
- type Mapper
- type MapperFunc
- type Runner
- type RunnerOption
- func RunnerWithHealth() RunnerOption
- func RunnerWithMaxBodySize(maxBodySize int64) RunnerOption
- func RunnerWithMiddlewares(middlewares ...func(http.Handler) http.Handler) RunnerOption
- func RunnerWithReadHeaderTimeout(readHeaderTimeout time.Duration) RunnerOption
- func RunnerWithShutdownTimeout(shutdownTimeout time.Duration) RunnerOption
- func RunnerWithTLSConfig(tlsConfig *tls.Config) RunnerOption
- func RunnerWithWalkFunc(walkFunc chi.WalkFunc) RunnerOption
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 ¶
This section is empty.
Types ¶
type HTTPHandlerMapperOption ¶
type HTTPHandlerMapperOption func(*httpHandlerMapper)
HTTPHandlerMapperOption is an option for a new HTTPHandlerMapper.
func HTTPHandlerMapperWithPrefix ¶
func HTTPHandlerMapperWithPrefix(prefix string) HTTPHandlerMapperOption
HTTPHandlerMapperWithPrefix returns a new HTTPHandlerMapperOption that uses the prefix.
type Mapper ¶
type Mapper interface {
Map(chi.Router) error
}
Mapper initializes a Router.
func NewHTTPHandlerMapper ¶
func NewHTTPHandlerMapper( handler http.Handler, options ...HTTPHandlerMapperOption, ) Mapper
NewHTTPHandlerMapper returns a new Mapper for the http.Handler.
type Runner ¶
type Runner interface { // Run runs the router. // // Blocking. // The runner is cancelled when the input context is cancelled. // The listener is closed upon return. // // Response write errors are logged. Response write errors can be ignored. // // Can be called multiple times, resulting in different runs. Run(ctx context.Context, listener net.Listener, mappers ...Mapper) error }
Runner is a runner.
type RunnerOption ¶
type RunnerOption func(*runner)
RunnerOption is an option for a new Runner.
func RunnerWithHealth ¶
func RunnerWithHealth() RunnerOption
RunnerWithHealth returns a new RunnerOption that turns a health check endpoint on at /health.
The default is to not turn on health.
func RunnerWithMaxBodySize ¶
func RunnerWithMaxBodySize(maxBodySize int64) RunnerOption
RunnerWithMaxBodySize returns a new RunnerOption that sets the max size of incoming request body.
The default is to not limit body size.
func RunnerWithMiddlewares ¶
func RunnerWithMiddlewares(middlewares ...func(http.Handler) http.Handler) RunnerOption
RunnerWithMiddlewares returns a new RunnerOption that use middlewares when the Runner Run.
func RunnerWithReadHeaderTimeout ¶
func RunnerWithReadHeaderTimeout(readHeaderTimeout time.Duration) RunnerOption
RunnerWithReadHeaderTimeout returns a new RunnerOption 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 RunnerWithShutdownTimeout ¶
func RunnerWithShutdownTimeout(shutdownTimeout time.Duration) RunnerOption
RunnerWithShutdownTimeout returns a new RunnerOption that uses the given shutdown timeout.
The default is to use DefaultShutdownTimeout. If shutdownTimeout is 0, no graceful shutdown will be performed.
func RunnerWithTLSConfig ¶
func RunnerWithTLSConfig(tlsConfig *tls.Config) RunnerOption
RunnerWithTLSConfig returns a new RunnerOption that uses the given tls.Config.
The default is to use no TLS.
func RunnerWithWalkFunc ¶
func RunnerWithWalkFunc(walkFunc chi.WalkFunc) RunnerOption
RunnerWithWalkFunc returns a new RunnerOption that runs chi.Walk to walk the router after all middlewares and routes have been mounted, but before the server is started.