Use go native embed lib for static assets

Use built in embed library to serve static files instead of the statik library
This commit is contained in:
Nicholas Thompson
2021-04-23 22:01:07 +02:00
parent f6c3b38976
commit d3576031bb
11 changed files with 6 additions and 29 deletions

View File

@@ -1,17 +1,14 @@
package static
import (
"github.com/rakyll/statik/fs"
"log"
"embed"
"net/http"
)
// New exports the static part of the webgui that is served via statik
//go:embed css js index.html favicon.ico
var content embed.FS
// New exports the static part of the webgui that is served via embed
func New() http.Handler {
statikFs, err := fs.New()
if err != nil {
log.Fatal(err)
}
return http.FileServer(statikFs)
return http.FileServer(http.FS(content))
}

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

File diff suppressed because one or more lines are too long