From 46a52a8691e83c81a6d12183eddf188b5d15f011 Mon Sep 17 00:00:00 2001 From: valentin v / vvval Date: Thu, 21 Feb 2019 15:17:40 +0300 Subject: Rename MaxRequest config param Added MaxRequestSize param, previous one is marked as deprecated, now they are merged --- service/http/config.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'service/http/config.go') diff --git a/service/http/config.go b/service/http/config.go index 5a2c8768..711939b7 100644 --- a/service/http/config.go +++ b/service/http/config.go @@ -17,8 +17,9 @@ type Config struct { // SSL defines https server options. SSL SSLConfig - // MaxRequest specified max size for payload body in megabytes, set 0 to unlimited. - MaxRequest int64 + // MaxRequestSize specified max size for payload body in megabytes, set 0 to unlimited. + MaxRequest int64 + MaxRequestSize int64 // Uploads configures uploads configuration. Uploads *UploadsConfig @@ -68,6 +69,7 @@ func (c *Config) Hydrate(cfg service.Config) error { return err } + c.mergeBackwardCompatibility() c.Workers.UpscaleDurations() return c.Valid() @@ -115,3 +117,9 @@ func (c *Config) Valid() error { return nil } + +func (c *Config) mergeBackwardCompatibility() { + if c.MaxRequestSize == 0 && c.MaxRequest != 0 { + c.MaxRequestSize = c.MaxRequest + } +} -- cgit v1.2.3 From cf3e341207893d62bae8a5671118401f745a8f08 Mon Sep 17 00:00:00 2001 From: valentin v / vvval Date: Thu, 21 Feb 2019 16:37:10 +0300 Subject: Add tests for MaxRequest merging --- service/http/config.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'service/http/config.go') diff --git a/service/http/config.go b/service/http/config.go index 711939b7..7549cb6c 100644 --- a/service/http/config.go +++ b/service/http/config.go @@ -17,8 +17,11 @@ type Config struct { // SSL defines https server options. SSL SSLConfig + // MaxRequest specified max size for payload body in megabytes, set 0 to unlimited. + // Deprecated: use `maxRequestSize` instead + MaxRequest int64 + // MaxRequestSize specified max size for payload body in megabytes, set 0 to unlimited. - MaxRequest int64 MaxRequestSize int64 // Uploads configures uploads configuration. @@ -118,6 +121,7 @@ func (c *Config) Valid() error { return nil } +// Perform merge operations for deprecated params to provide backward compatibility func (c *Config) mergeBackwardCompatibility() { if c.MaxRequestSize == 0 && c.MaxRequest != 0 { c.MaxRequestSize = c.MaxRequest -- cgit v1.2.3 From e6d2972c9f69fefe169be448b18ce776cd4a8fa5 Mon Sep 17 00:00:00 2001 From: Wolfy-J Date: Thu, 2 May 2019 16:35:37 +0300 Subject: remove old param --- service/http/config.go | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'service/http/config.go') diff --git a/service/http/config.go b/service/http/config.go index 7549cb6c..899a5083 100644 --- a/service/http/config.go +++ b/service/http/config.go @@ -17,10 +17,6 @@ type Config struct { // SSL defines https server options. SSL SSLConfig - // MaxRequest specified max size for payload body in megabytes, set 0 to unlimited. - // Deprecated: use `maxRequestSize` instead - MaxRequest int64 - // MaxRequestSize specified max size for payload body in megabytes, set 0 to unlimited. MaxRequestSize int64 @@ -72,7 +68,6 @@ func (c *Config) Hydrate(cfg service.Config) error { return err } - c.mergeBackwardCompatibility() c.Workers.UpscaleDurations() return c.Valid() @@ -120,10 +115,3 @@ func (c *Config) Valid() error { return nil } - -// Perform merge operations for deprecated params to provide backward compatibility -func (c *Config) mergeBackwardCompatibility() { - if c.MaxRequestSize == 0 && c.MaxRequest != 0 { - c.MaxRequestSize = c.MaxRequest - } -} -- cgit v1.2.3