尝试修复非图片文件的重定向问题,并优化了代码结构。

This commit is contained in:
wood chen 2024-09-29 15:17:45 +08:00
parent 0b494e08ac
commit 585f9a52b8
2 changed files with 45 additions and 49 deletions

View File

@ -1,4 +1,4 @@
FROM golang:1.23-bookworm as builder FROM golang:1.23-bookworm AS builder
ARG IMG_PATH=/opt/pics ARG IMG_PATH=/opt/pics
ARG EXHAUST_PATH=/opt/exhaust ARG EXHAUST_PATH=/opt/exhaust

View File

@ -3,21 +3,19 @@ package handler
import ( import (
"net/http" "net/http"
"net/url" "net/url"
"path"
"regexp" "regexp"
"slices"
"strconv"
"strings" "strings"
"webp_server_go/config" "webp_server_go/config"
"webp_server_go/encoder" "webp_server_go/encoder"
"webp_server_go/helper" "webp_server_go/helper"
"slices"
"path"
"strconv"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
func Convert(c *fiber.Ctx) error { func Convert(c *fiber.Ctx) error {
// this function need to do: // this function need to do:
// 1. get request path, query string // 1. get request path, query string
@ -65,8 +63,6 @@ func Convert(c *fiber.Ctx) error {
// //
// //
// //
reqURI := c.Path()
filename := path.Base(reqURI)
// 处理根路径请求 // 处理根路径请求
if reqURI == "/" { if reqURI == "/" {