mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 05:32:02 +08:00
修复了路径检查和根路径请求的处理,优化了代码结构。
This commit is contained in:
parent
585f9a52b8
commit
b85b0c6260
@ -23,9 +23,14 @@ func Convert(c *fiber.Ctx) error {
|
||||
// 3. pass it to encoder, get the result, send it back
|
||||
|
||||
// normal http request will start with /
|
||||
// 检查路径是否以 "/" 开头
|
||||
if !strings.HasPrefix(c.Path(), "/") {
|
||||
_ = c.SendStatus(http.StatusBadRequest)
|
||||
return nil
|
||||
return c.SendStatus(http.StatusBadRequest)
|
||||
}
|
||||
|
||||
// 处理根路径请求
|
||||
if c.Path() == "/" {
|
||||
return c.SendString("Welcome to WebP Server")
|
||||
}
|
||||
|
||||
var (
|
||||
@ -64,12 +69,6 @@ func Convert(c *fiber.Ctx) error {
|
||||
//
|
||||
//
|
||||
|
||||
// 处理根路径请求
|
||||
if reqURI == "/" {
|
||||
// 重定向到一个适当的页面或返回一个默认响应
|
||||
return c.SendString("Welcome to WebP Server")
|
||||
}
|
||||
|
||||
if !isImageFile(filename) {
|
||||
log.Infof("Non-image file requested: %s, redirecting to original URL", reqURI)
|
||||
var redirectURL string
|
||||
|
Loading…
x
Reference in New Issue
Block a user