mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-06 15:22:47 +01:00
25 lines
441 B
Go
25 lines
441 B
Go
package catalyst
|
|
|
|
import (
|
|
"io/fs"
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/SecurityBrewery/catalyst/ui"
|
|
)
|
|
|
|
func static(ctx *gin.Context) {
|
|
fsys, _ := fs.Sub(ui.UI, "dist")
|
|
|
|
upath := strings.TrimPrefix(ctx.Request.URL.Path, "/")
|
|
|
|
if _, err := fs.Stat(fsys, upath); err != nil {
|
|
ctx.Request.URL.Path = "/"
|
|
ctx.Request.URL.RawPath = "/"
|
|
}
|
|
|
|
http.FileServer(http.FS(fsys)).ServeHTTP(ctx.Writer, ctx.Request)
|
|
}
|