31 lines
756 B
Go
Raw Permalink Normal View History

2024-03-22 14:08:24 +00:00
package web
2024-03-12 21:31:45 +00:00
import "time"
2024-03-22 14:18:54 +00:00
// config represents the server configuration.
type config struct {
Timeout timeoutConfig `json:"timeout"`
2024-03-12 21:31:45 +00:00
}
2024-03-22 14:18:54 +00:00
// timeoutConfig lets you configure the different timeout durations.
type timeoutConfig struct {
2024-03-12 21:31:45 +00:00
Idle time.Duration `json:"idle"`
Read time.Duration `json:"read"`
ReadHeader time.Duration `json:"readHeader"`
Write time.Duration `json:"write"`
Shutdown time.Duration `json:"shutdown"`
}
// Reset resets all fields to the default configuration.
2024-03-22 14:18:54 +00:00
func defaultConfig() config {
return config{
Timeout: timeoutConfig{
2024-03-12 21:31:45 +00:00
Idle: 3 * time.Minute,
Write: 2 * time.Minute,
Read: 5 * time.Second,
ReadHeader: 5 * time.Second,
Shutdown: 250 * time.Millisecond,
},
}
}