Rejig embedded assets to a central folder

This commit is contained in:
Jamie Curnow
2021-06-30 10:50:55 +10:00
parent 4be9d4d509
commit 80a31b3041
71 changed files with 38 additions and 20 deletions

View File

@@ -1,7 +1,6 @@
package handler
import (
"embed"
"errors"
"io"
"io/fs"
@@ -10,19 +9,19 @@ import (
"path/filepath"
"strings"
"npm/embed"
h "npm/internal/api/http"
)
//go:embed assets
var assets embed.FS
var assetsSub fs.FS
var errIsDir = errors.New("path is dir")
var (
assetsSub fs.FS
errIsDir = errors.New("path is dir")
)
// NotFound is a json error handler for 404's and method not allowed.
// It also serves the react frontend as embedded files in the golang binary.
func NotFound() func(http.ResponseWriter, *http.Request) {
assetsSub, _ = fs.Sub(assets, "assets")
assetsSub, _ = fs.Sub(embed.Assets, "assets")
return func(w http.ResponseWriter, r *http.Request) {
path := strings.TrimLeft(r.URL.Path, "/")