mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
c9e8a924e0
* implement read buffer size config option * implement write buffer size config option * implement fasthttp ErrorHandler so we can log errors to Authelia as well * add struct/schema validation * add default value * add docs * add config key to validator * refactoring * apply suggestions from code review Co-authored-by: Amir Zarrinkafsh <nightah@me.com>
26 lines
769 B
Go
26 lines
769 B
Go
package validator
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/authelia/authelia/internal/configuration/schema"
|
|
)
|
|
|
|
var defaultReadBufferSize = 4096
|
|
var defaultWriteBufferSize = 4096
|
|
|
|
// ValidateServer checks a server configuration is correct.
|
|
func ValidateServer(configuration *schema.ServerConfiguration, validator *schema.StructValidator) {
|
|
if configuration.ReadBufferSize == 0 {
|
|
configuration.ReadBufferSize = defaultReadBufferSize
|
|
} else if configuration.ReadBufferSize < 0 {
|
|
validator.Push(fmt.Errorf("server read buffer size must be above 0"))
|
|
}
|
|
|
|
if configuration.WriteBufferSize == 0 {
|
|
configuration.WriteBufferSize = defaultWriteBufferSize
|
|
} else if configuration.WriteBufferSize < 0 {
|
|
validator.Push(fmt.Errorf("server write buffer size must be above 0"))
|
|
}
|
|
}
|