mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
refactor(router): simplify file path construction in Convert function
This commit is contained in:
parent
740aae4f98
commit
f241273bc4
@ -63,7 +63,7 @@ func Convert(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 构建 EXHAUST_PATH 中的文件路径
|
// 构建 EXHAUST_PATH 中的文件路径
|
||||||
exhaustFilename := path.Join(config.Config.ExhaustPath, strings.TrimPrefix(reqURI, matchedPrefix))
|
exhaustFilename := path.Join(config.Config.ExhaustPath, reqURI)
|
||||||
if extraParams.Width > 0 || extraParams.Height > 0 || extraParams.MaxWidth > 0 || extraParams.MaxHeight > 0 {
|
if extraParams.Width > 0 || extraParams.Height > 0 || extraParams.MaxWidth > 0 || extraParams.MaxHeight > 0 {
|
||||||
ext := path.Ext(exhaustFilename)
|
ext := path.Ext(exhaustFilename)
|
||||||
extraParamsStr := fmt.Sprintf("_w%d_h%d_mw%d_mh%d", extraParams.Width, extraParams.Height, extraParams.MaxWidth, extraParams.MaxHeight)
|
extraParamsStr := fmt.Sprintf("_w%d_h%d_mw%d_mh%d", extraParams.Width, extraParams.Height, extraParams.MaxWidth, extraParams.MaxHeight)
|
||||||
@ -88,8 +88,7 @@ func Convert(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
if isLocalPath {
|
if isLocalPath {
|
||||||
// 处理本地路径
|
// 处理本地路径
|
||||||
localPath := strings.TrimPrefix(reqURI, matchedPrefix)
|
rawImageAbs = path.Join(matchedTarget, reqURI)
|
||||||
rawImageAbs = path.Join(matchedTarget, localPath)
|
|
||||||
|
|
||||||
// 检查本地文件是否存在
|
// 检查本地文件是否存在
|
||||||
if !helper.FileExists(rawImageAbs) {
|
if !helper.FileExists(rawImageAbs) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user