From 64679682e1cff63dab39498745b51ae592457b07 Mon Sep 17 00:00:00 2001 From: Thanatat Tamtan Date: Sun, 18 Apr 2021 17:14:53 +0700 Subject: [PATCH] add eTag to AppConfig --- config.go | 7 ++++++- config_test.go | 1 + testdata/config1.yaml | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index b2a3e9b..7f9964e 100644 --- a/config.go +++ b/config.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "time" - yaml "gopkg.in/yaml.v3" + "gopkg.in/yaml.v3" ) // AppConfig is hime app's config @@ -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"` @@ -65,6 +66,7 @@ func parseDuration(s string, t *time.Duration) { // readHeaderTimeout: 5s // writeTimeout: 5s // idleTimeout: 30s +// eTag: true // gracefulShutdown: // timeout: 1m // wait: 5s @@ -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() diff --git a/config_test.go b/config_test.go index 548a74f..a7556bf 100644 --- a/config_test.go +++ b/config_test.go @@ -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 diff --git a/testdata/config1.yaml b/testdata/config1.yaml index d8a99fe..a4c1d4a 100644 --- a/testdata/config1.yaml +++ b/testdata/config1.yaml @@ -23,6 +23,7 @@ server: writeTimeout: 6s idleTimeout: 30s reusePort: true + eTag: true tcpKeepAlive: 1m gracefulShutdown: timeout: 1m