From f5b4f268dc73078467f19faf6068cc8047cabc7f Mon Sep 17 00:00:00 2001 From: Matt Holt Date: Mon, 10 Jun 2019 10:21:25 -0600 Subject: Implement encode middleware (#2) * Implement encode middleware * Add missing break; and add missing JSON struct field tag --- modules/caddyhttp/encode/zstd/zstd.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 modules/caddyhttp/encode/zstd/zstd.go (limited to 'modules/caddyhttp/encode/zstd') 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 +} -- cgit v1.2.3