Remove dependency of go-bindata (#818)
* Use new embed functionality for serving UI assets * Use new embed functionality for serving resources. Remove dependency on go-bindata * Remove Go 1.15
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package resources
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
//go:embed *
|
||||
var filesystem embed.FS
|
||||
|
||||
func Asset(path string) ([]byte, error) {
|
||||
f, err := filesystem.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ioutil.ReadAll(f)
|
||||
}
|
||||
|
||||
func Assets() fs.FS {
|
||||
return filesystem
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
// +build !embed
|
||||
|
||||
package resources
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/navidrome/navidrome/log"
|
||||
)
|
||||
|
||||
var once sync.Once
|
||||
|
||||
func Asset(filePath string) ([]byte, error) {
|
||||
f, err := AssetFile().Open(filePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ioutil.ReadAll(f)
|
||||
}
|
||||
|
||||
func AssetFile() http.FileSystem {
|
||||
once.Do(func() {
|
||||
log.Warn("Using external resources from 'resources' folder")
|
||||
})
|
||||
return http.Dir("resources")
|
||||
}
|
||||
Reference in New Issue
Block a user