go(settings): expose default server timeouts
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
4ccec7857d
commit
e941e73222
@ -6,7 +6,6 @@ package app
|
|||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gorilla/sessions"
|
"github.com/gorilla/sessions"
|
||||||
"github.com/labstack/echo-contrib/session"
|
"github.com/labstack/echo-contrib/session"
|
||||||
@ -46,8 +45,8 @@ func (a *App) SetEchoSettings() {
|
|||||||
// }))
|
// }))
|
||||||
|
|
||||||
// TODO: make this configurable.
|
// TODO: make this configurable.
|
||||||
e.Server.WriteTimeout = 30 * time.Second
|
e.Server.WriteTimeout = a.setting.DefaultServerWriteTimeout()
|
||||||
e.Server.ReadHeaderTimeout = 30 * time.Second
|
e.Server.ReadHeaderTimeout = a.setting.DefaultServerReadHeaderTimeout()
|
||||||
|
|
||||||
if a.setting.HTTPRateLimitEnabled() {
|
if a.setting.HTTPRateLimitEnabled() {
|
||||||
limit := rate.Limit(a.setting.HTTPRateLimit())
|
limit := rate.Limit(a.setting.HTTPRateLimit())
|
||||||
|
@ -5,6 +5,7 @@ package settings
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.dotya.ml/mirre-mt/pcmt/config"
|
"git.dotya.ml/mirre-mt/pcmt/config"
|
||||||
"git.dotya.ml/mirre-mt/pcmt/slogging"
|
"git.dotya.ml/mirre-mt/pcmt/slogging"
|
||||||
@ -45,6 +46,8 @@ const (
|
|||||||
defaultPort = 3000
|
defaultPort = 3000
|
||||||
defaultSessionMaxAge = 86400 // seconds.
|
defaultSessionMaxAge = 86400 // seconds.
|
||||||
defaultHTTPDomain = "localhost"
|
defaultHTTPDomain = "localhost"
|
||||||
|
defaultServerWriteTimeout = 30 * time.Second
|
||||||
|
defaultServerReadHeaderTimeout = 30 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
// cleantgt is a list of ENV vars pertaining to pcmt.
|
// cleantgt is a list of ENV vars pertaining to pcmt.
|
||||||
@ -63,6 +66,16 @@ func New() *Settings {
|
|||||||
return &Settings{}
|
return &Settings{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DefaultServerWriteTimeout returns the server default write timeout.
|
||||||
|
func (s *Settings) DefaultServerWriteTimeout() time.Duration {
|
||||||
|
return defaultServerWriteTimeout
|
||||||
|
}
|
||||||
|
|
||||||
|
// DefaultServerReadHeaderTimeout returns the server default read header timeout.
|
||||||
|
func (s *Settings) DefaultServerReadHeaderTimeout() time.Duration {
|
||||||
|
return defaultServerReadHeaderTimeout
|
||||||
|
}
|
||||||
|
|
||||||
// Consolidate reconciles whatever values are set in config and via flags and
|
// Consolidate reconciles whatever values are set in config and via flags and
|
||||||
// sets it to one place that should be regarded as a single source of truth -
|
// sets it to one place that should be regarded as a single source of truth -
|
||||||
// the settings struct. Order of preference for values is (from higher to
|
// the settings struct. Order of preference for values is (from higher to
|
||||||
|
Loading…
Reference in New Issue
Block a user