summaryrefslogtreecommitdiff
path: root/plugins/gzip/plugin.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-11-30 11:24:00 +0300
committerGitHub <[email protected]>2020-11-30 11:24:00 +0300
commita7f1952bc80f28985dde7da6446342a774464e24 (patch)
tree12e1261102ff417f5d4077ce34f754527a135478 /plugins/gzip/plugin.go
parentb5020bfce6b5362400cb9b578fe32c1a6ed5d61a (diff)
parentb27564251f4dbb8e366a4940d79a5645e2b28d3c (diff)
Merge pull request #418 from spiral/plugin/gzip
Gzip plugin
Diffstat (limited to 'plugins/gzip/plugin.go')
-rw-r--r--plugins/gzip/plugin.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/gzip/plugin.go b/plugins/gzip/plugin.go
new file mode 100644
index 00000000..f5a0f4ea
--- /dev/null
+++ b/plugins/gzip/plugin.go
@@ -0,0 +1,26 @@
+package gzip
+
+import (
+ "net/http"
+
+ "github.com/NYTimes/gziphandler"
+)
+
+const PluginName = "gzip"
+
+type Gzip struct {
+}
+
+func (g *Gzip) Init() error {
+ return nil
+}
+
+func (g *Gzip) Middleware(next http.Handler) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ gziphandler.GzipHandler(next).ServeHTTP(w, r)
+ }
+}
+
+func (g *Gzip) Name() string {
+ return PluginName
+}