Move static to resources. Embed them at build time

This commit is contained in:
Deluan
2020-05-01 14:35:57 -04:00
committed by Deluan Quintão
parent b7dcdedf41
commit 1a9663d432
13 changed files with 39 additions and 367 deletions
+28
View File
@@ -0,0 +1,28 @@
// +build !embed
package resources
import (
"io/ioutil"
"net/http"
"sync"
"github.com/deluan/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")
}