summaryrefslogtreecommitdiff
path: root/service/gzip/service.go
diff options
context:
space:
mode:
Diffstat (limited to 'service/gzip/service.go')
-rw-r--r--service/gzip/service.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/service/gzip/service.go b/service/gzip/service.go
index bb6bcfcd..231ba4d9 100644
--- a/service/gzip/service.go
+++ b/service/gzip/service.go
@@ -1,6 +1,7 @@
package gzip
import (
+ "errors"
"github.com/NYTimes/gziphandler"
rrhttp "github.com/spiral/roadrunner/service/http"
"net/http"
@@ -8,6 +9,7 @@ import (
// ID contains default service name.
const ID = "gzip"
+var httpNotInitialized = errors.New("http service should be defined properly in config to use gzip")
type Service struct {
cfg *Config
@@ -15,10 +17,12 @@ type Service struct {
func (s *Service) Init(cfg *Config, r *rrhttp.Service) (bool, error) {
s.cfg = cfg
-
if !s.cfg.Enable {
return false, nil
}
+ if r == nil {
+ return false, httpNotInitialized
+ }
r.AddMiddleware(s.middleware)