feat: multi-feature update
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user