feat: multi-feature update

This commit is contained in:
chaos
2026-06-15 06:16:16 +08:00
parent 6f415428d3
commit 04d30f9dd1
58 changed files with 4610 additions and 419 deletions
+12 -1
View File
@@ -5,6 +5,7 @@ import (
"io/fs"
"net/http"
"os"
"strings"
"github.com/gin-contrib/static"
)
@@ -16,7 +17,17 @@ type embedFileSystem struct {
}
func (e *embedFileSystem) Exists(prefix string, path string) bool {
_, err := e.Open(path)
// gin-contrib/static passes the raw URL path (e.g. "/image-gen/assets/x.js")
// together with the URL prefix we registered (e.g. "/image-gen"). The
// underlying fs.Sub FS only knows about the sub-tree (no prefix), so we
// must strip the prefix before asking it whether the file exists. An
// empty prefix means "served at /" — nothing to strip.
p := strings.TrimPrefix(path, prefix)
if p == path {
// prefix didn't match — definitely not in this FS
return false
}
_, err := e.Open(p)
if err != nil {
return false
}