Skip to content

Commit

Permalink
add eTag to AppConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
acoshift committed Apr 18, 2021
1 parent 2430329 commit 6467968
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"io/ioutil"
"time"

yaml "gopkg.in/yaml.v3"
"gopkg.in/yaml.v3"
)

// AppConfig is hime app's config
Expand All @@ -20,6 +20,7 @@ type AppConfig struct {
IdleTimeout string `yaml:"idleTimeout" json:"idleTimeout"`
ReusePort *bool `yaml:"reusePort" json:"reusePort"`
TCPKeepAlive string `yaml:"tcpKeepAlive" json:"tcpKeepAlive"`
ETag *bool `yaml:"eTag" json:"eTag"`
GracefulShutdown *GracefulShutdown `yaml:"gracefulShutdown" json:"gracefulShutdown"`
TLS *TLS `yaml:"tls" json:"tls"`
HTTPSRedirect *HTTPSRedirect `yaml:"httpsRedirect" json:"httpsRedirect"`
Expand Down Expand Up @@ -65,6 +66,7 @@ func parseDuration(s string, t *time.Duration) {
// readHeaderTimeout: 5s
// writeTimeout: 5s
// idleTimeout: 30s
// eTag: true
// gracefulShutdown:
// timeout: 1m
// wait: 5s
Expand Down Expand Up @@ -92,6 +94,9 @@ func (app *App) Config(config AppConfig) *App {
if server.ReusePort != nil {
app.reusePort = *server.ReusePort
}
if server.ETag != nil {
app.ETag = *server.ETag
}

if t := server.TLS; t != nil {
app.srv.TLSConfig = server.TLS.config()
Expand Down
1 change: 1 addition & 0 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestConfig(t *testing.T) {
assert.Equal(t, app.srv.IdleTimeout, 30*time.Second)
assert.Equal(t, app.tcpKeepAlive, time.Minute)
assert.True(t, app.reusePort)
assert.True(t, app.ETag)
assert.Len(t, app.srv.TLSConfig.Certificates, 1)

// graceful
Expand Down
1 change: 1 addition & 0 deletions testdata/config1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ server:
writeTimeout: 6s
idleTimeout: 30s
reusePort: true
eTag: true
tcpKeepAlive: 1m
gracefulShutdown:
timeout: 1m
Expand Down

0 comments on commit 6467968

Please sign in to comment.