summaryrefslogtreecommitdiff
path: root/service/gzip/service.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-03-14 01:29:59 +0300
committerValery Piashchynski <[email protected]>2020-03-14 01:29:59 +0300
commit5e4c32f90db8ae6de541598304907974762f1673 (patch)
tree30b7197025d7830dd8575b850a3685d11d27fbfc /service/gzip/service.go
parent4ae5a7e7213798892d511a7a53ecd148e22ca7f6 (diff)
Fix potencial issue in gzip with cfg initialization
Add test for bug 275
Diffstat (limited to 'service/gzip/service.go')
-rw-r--r--service/gzip/service.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/service/gzip/service.go b/service/gzip/service.go
index 5ae3ffd5..231ba4d9 100644
--- a/service/gzip/service.go
+++ b/service/gzip/service.go
@@ -9,21 +9,20 @@ import (
// ID contains default service name.
const ID = "gzip"
-var httpNotInitialized = errors.New("http service should be defined properly in config")
+var httpNotInitialized = errors.New("http service should be defined properly in config to use gzip")
type Service struct {
cfg *Config
}
func (s *Service) Init(cfg *Config, r *rrhttp.Service) (bool, error) {
- if r == nil {
- return false, httpNotInitialized
- }
s.cfg = cfg
-
if !s.cfg.Enable {
return false, nil
}
+ if r == nil {
+ return false, httpNotInitialized
+ }
r.AddMiddleware(s.middleware)