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
585f9a52b8
commit
b85b0c6260
@ -23,9 +23,14 @@ func Convert(c *fiber.Ctx) error {
|
|||||||
// 3. pass it to encoder, get the result, send it back
|
// 3. pass it to encoder, get the result, send it back
|
||||||
|
|
||||||
// normal http request will start with /
|
// normal http request will start with /
|
||||||
|
// 检查路径是否以 "/" 开头
|
||||||
if !strings.HasPrefix(c.Path(), "/") {
|
if !strings.HasPrefix(c.Path(), "/") {
|
||||||
_ = c.SendStatus(http.StatusBadRequest)
|
return c.SendStatus(http.StatusBadRequest)
|
||||||
return nil
|
}
|
||||||
|
|
||||||
|
// 处理根路径请求
|
||||||
|
if c.Path() == "/" {
|
||||||
|
return c.SendString("Welcome to WebP Server")
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -64,12 +69,6 @@ func Convert(c *fiber.Ctx) error {
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
// 处理根路径请求
|
|
||||||
if reqURI == "/" {
|
|
||||||
// 重定向到一个适当的页面或返回一个默认响应
|
|
||||||
return c.SendString("Welcome to WebP Server")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !isImageFile(filename) {
|
if !isImageFile(filename) {
|
||||||
log.Infof("Non-image file requested: %s, redirecting to original URL", reqURI)
|
log.Infof("Non-image file requested: %s, redirecting to original URL", reqURI)
|
||||||
var redirectURL string
|
var redirectURL string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user