31 lines
812 B
Go
Raw Normal View History

2024-03-22 14:08:24 +00:00
package web
2024-03-12 21:31:45 +00:00
import "time"
// Configuration represents the server configuration.
type Configuration struct {
2024-03-16 14:26:45 +00:00
Timeout TimeoutConfiguration `json:"timeout"`
2024-03-12 21:31:45 +00:00
}
// TimeoutConfiguration lets you configure the different timeout durations.
type TimeoutConfiguration struct {
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.
func defaultConfig() Configuration {
return Configuration{
Timeout: TimeoutConfiguration{
Idle: 3 * time.Minute,
Write: 2 * time.Minute,
Read: 5 * time.Second,
ReadHeader: 5 * time.Second,
Shutdown: 250 * time.Millisecond,
},
}
}