mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-07 15:52:47 +01:00
23 lines
385 B
Go
23 lines
385 B
Go
package catalyst
|
|
|
|
import (
|
|
"io/fs"
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/SecurityBrewery/catalyst/ui"
|
|
)
|
|
|
|
func static(w http.ResponseWriter, r *http.Request) {
|
|
fsys, _ := fs.Sub(ui.UI, "dist")
|
|
|
|
upath := strings.TrimPrefix(r.URL.Path, "/")
|
|
|
|
if _, err := fs.Stat(fsys, upath); err != nil {
|
|
r.URL.Path = "/"
|
|
r.URL.RawPath = "/"
|
|
}
|
|
|
|
http.FileServer(http.FS(fsys)).ServeHTTP(w, r)
|
|
}
|