mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2026-01-23 22:43:27 +01:00
12
static.go
12
static.go
@@ -5,20 +5,18 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/ui"
|
||||
)
|
||||
|
||||
func static(ctx *gin.Context) {
|
||||
func static(w http.ResponseWriter, r *http.Request) {
|
||||
fsys, _ := fs.Sub(ui.UI, "dist")
|
||||
|
||||
upath := strings.TrimPrefix(ctx.Request.URL.Path, "/")
|
||||
upath := strings.TrimPrefix(r.URL.Path, "/")
|
||||
|
||||
if _, err := fs.Stat(fsys, upath); err != nil {
|
||||
ctx.Request.URL.Path = "/"
|
||||
ctx.Request.URL.RawPath = "/"
|
||||
r.URL.Path = "/"
|
||||
r.URL.RawPath = "/"
|
||||
}
|
||||
|
||||
http.FileServer(http.FS(fsys)).ServeHTTP(ctx.Writer, ctx.Request)
|
||||
http.FileServer(http.FS(fsys)).ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user