diff --git a/caddywebp.go b/caddywebp.go index 8c0b1c2..fdb0bf0 100644 --- a/caddywebp.go +++ b/caddywebp.go @@ -3,11 +3,6 @@ package caddywebp import ( "bytes" "fmt" - "github.com/caddyserver/caddy/v2" - "github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile" - "github.com/caddyserver/caddy/v2/modules/caddyhttp" - "github.com/chai2010/webp" - "golang.org/x/image/bmp" "image" "image/gif" "image/jpeg" @@ -18,6 +13,12 @@ import ( "os" "path" "strings" + + "github.com/caddyserver/caddy/v2" + "github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile" + "github.com/caddyserver/caddy/v2/modules/caddyhttp" + "github.com/chai2010/webp" + "golang.org/x/image/bmp" ) const Quality = 80 @@ -109,8 +110,9 @@ func (s Webp) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.H case "image/gif": decoder = decodeGif default: - next.ServeHTTP(w, r) + return next.ServeHTTP(w, r) } + img, err := decoder(bytes.NewReader(resp.Body.Bytes())) if err != nil || img == nil { log.Println(err)