20 lines
556 B
Go
20 lines
556 B
Go
|
|
package server
|
||
|
|
|
||
|
|
import "net/http"
|
||
|
|
|
||
|
|
// Option configures a [Server] at construction time.
|
||
|
|
type Option func(*serverOpts)
|
||
|
|
|
||
|
|
// WithMiddleware registers one or more middleware functions applied to the
|
||
|
|
// root chi router during [lifecycle.Component.OnInit].
|
||
|
|
// Middleware is applied in registration order (outermost first).
|
||
|
|
func WithMiddleware(middleware ...func(http.Handler) http.Handler) Option {
|
||
|
|
return func(o *serverOpts) {
|
||
|
|
o.middleware = append(o.middleware, middleware...)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
type serverOpts struct {
|
||
|
|
middleware []func(http.Handler) http.Handler
|
||
|
|
}
|