mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
尝试修复非图片文件的重定向问题,并优化了代码结构。
This commit is contained in:
parent
0b494e08ac
commit
585f9a52b8
@ -1,4 +1,4 @@
|
||||
FROM golang:1.23-bookworm as builder
|
||||
FROM golang:1.23-bookworm AS builder
|
||||
|
||||
ARG IMG_PATH=/opt/pics
|
||||
ARG EXHAUST_PATH=/opt/exhaust
|
||||
|
@ -3,21 +3,19 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"webp_server_go/config"
|
||||
"webp_server_go/encoder"
|
||||
"webp_server_go/helper"
|
||||
"slices"
|
||||
"path"
|
||||
"strconv"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
||||
|
||||
func Convert(c *fiber.Ctx) error {
|
||||
// this function need to do:
|
||||
// 1. get request path, query string
|
||||
@ -61,12 +59,10 @@ func Convert(c *fiber.Ctx) error {
|
||||
|
||||
log.Debugf("Incoming connection from %s %s %s", c.IP(), reqHostname, reqURIwithQuery)
|
||||
|
||||
// 非图片清况下302到源文件
|
||||
//
|
||||
//
|
||||
//
|
||||
reqURI := c.Path()
|
||||
filename := path.Base(reqURI)
|
||||
// 非图片清况下302到源文件
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
// 处理根路径请求
|
||||
if reqURI == "/" {
|
||||
@ -106,8 +102,8 @@ func Convert(c *fiber.Ctx) error {
|
||||
return c.Redirect(redirectURL, fiber.StatusFound)
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
if !helper.CheckAllowedType(filename) {
|
||||
msg := "File extension not allowed! " + filename
|
||||
|
Loading…
x
Reference in New Issue
Block a user