Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTMLpack ¶ added in v0.16.0
func HTMLpack(router *chi.Mux, log zerolog.Logger, conf WebpackOpts)
HTMLPack sets a reasonable set of middleware in the right order taking into consideration those that defer computation(especially)
The middleware set up includes:
- Automatic Request IDs
- Real IP middleware
- Compressing response body
- Request Logging
- Response time header
- Panic Recovery(with special support for api.Error)
- Timeouts on request context
func Webpack ¶
func Webpack(router *chi.Mux, log zerolog.Logger, conf WebpackOpts)
Webpack sets a reasonable set of middleware in the right order taking into consideration those that defer computation(especially)
The middleware set up includes:
- Automatic Request IDs
- Response time middleware and header(and metrics if a registry is passed)
- Real IP middleware
- Middleware for hanging slashes
- Compressing response body
- CORS handling for dev and production
- Request Logging
- Panic Recovery(with special support for api.Error)
- Timeouts on request context
Types ¶
type WebpackOpts ¶
type WebpackOpts struct { Environment string // Application environment(dev, test e.t.c.) Timeout time.Duration // Duration before request context times out. Defaults to 1 minute CompressionLevel int // Level of compression for responses, ranging from 1-9. Defaults to 5 CORSOrigins []string // list of allowed origins Registry prometheus.Registerer // registry for prometheus. This is where we add response time collector }
WebpackOpts are configuration values for the Webpack middleware