summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/encode/zstd
diff options
context:
space:
mode:
authorMatt Holt <mholt@users.noreply.github.com>2019-06-10 10:21:25 -0600
committerGitHub <noreply@github.com>2019-06-10 10:21:25 -0600
commitf5b4f268dc73078467f19faf6068cc8047cabc7f (patch)
treebf44b5e31f83483c5f3e90762aa39452ec02f7d2 /modules/caddyhttp/encode/zstd
parentef5f29cfb257c7503763a4b16947c4eb6a7864c3 (diff)
Implement encode middleware (#2)
* Implement encode middleware * Add missing break; and add missing JSON struct field tag
Diffstat (limited to 'modules/caddyhttp/encode/zstd')
-rw-r--r--modules/caddyhttp/encode/zstd/zstd.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/modules/caddyhttp/encode/zstd/zstd.go b/modules/caddyhttp/encode/zstd/zstd.go
new file mode 100644
index 0000000..6afe53e
--- /dev/null
+++ b/modules/caddyhttp/encode/zstd/zstd.go
@@ -0,0 +1,23 @@
+package caddystd
+
+import (
+ "github.com/caddyserver/caddy2"
+ "github.com/caddyserver/caddy2/modules/caddyhttp/encode"
+ "github.com/klauspost/compress/zstd"
+)
+
+func init() {
+ caddy2.RegisterModule(caddy2.Module{
+ Name: "http.encoders.zstd",
+ New: func() interface{} { return new(Zstd) },
+ })
+}
+
+// Zstd can create zstd encoders.
+type Zstd struct{}
+
+// NewEncoder returns a new gzip writer.
+func (z Zstd) NewEncoder() encode.Encoder {
+ writer, _ := zstd.NewWriter(nil)
+ return writer
+}