2021-05-11 22:59:05 +00:00
|
|
|
package httputil
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Option sets an optional parameter of Server.
|
|
|
|
type Option func(*cfg)
|
|
|
|
|
|
|
|
type cfg struct {
|
|
|
|
shutdownTimeout time.Duration
|
|
|
|
}
|
|
|
|
|
|
|
|
func defaultCfg() *cfg {
|
|
|
|
return &cfg{
|
|
|
|
shutdownTimeout: 15 * time.Second,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// WithShutdownTimeout returns an option to set shutdown timeout
|
2021-05-11 22:59:05 +00:00
|
|
|
// of the internal HTTP server.
|
|
|
|
func WithShutdownTimeout(dur time.Duration) Option {
|
|
|
|
return func(c *cfg) {
|
|
|
|
c.shutdownTimeout = dur
|
|
|
|
}
|
|
|
|
}
|