Release catalyst

This commit is contained in:
Jonas Plum
2021-12-13 00:39:15 +01:00
commit 15cf0ebd49
339 changed files with 111677 additions and 0 deletions

24
static.go Normal file
View File

@@ -0,0 +1,24 @@
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)
}