fix return

This commit is contained in:
shortcut 2022-07-25 15:14:46 -04:00
parent 89dbed4b67
commit 9c3c67abed
1 changed files with 8 additions and 6 deletions

View File

@ -3,11 +3,6 @@ package caddywebp
import ( import (
"bytes" "bytes"
"fmt" "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"
"image/gif" "image/gif"
"image/jpeg" "image/jpeg"
@ -18,6 +13,12 @@ import (
"os" "os"
"path" "path"
"strings" "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 const Quality = 80
@ -109,8 +110,9 @@ func (s Webp) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.H
case "image/gif": case "image/gif":
decoder = decodeGif decoder = decodeGif
default: default:
next.ServeHTTP(w, r) return next.ServeHTTP(w, r)
} }
img, err := decoder(bytes.NewReader(resp.Body.Bytes())) img, err := decoder(bytes.NewReader(resp.Body.Bytes()))
if err != nil || img == nil { if err != nil || img == nil {
log.Println(err) log.Println(err)