react: use fs.FS instead of embed.FS

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
Adphi 2023-01-20 14:33:52 +01:00
parent 926af303e8
commit 8f75b6aca4
Signed by: adphi
GPG Key ID: 46BE4062DB2397FF
1 changed files with 2 additions and 3 deletions

View File

@ -15,7 +15,6 @@
package react package react
import ( import (
"embed"
"io/fs" "io/fs"
"net/http" "net/http"
"net/http/httputil" "net/http/httputil"
@ -28,14 +27,14 @@ const (
EndpointEnv = "REACT_ENDPOINT" EndpointEnv = "REACT_ENDPOINT"
) )
func NewHandler(dir embed.FS, subpath string) (http.Handler, error) { func NewHandler(dir fs.FS, subpath string) (http.Handler, error) {
if e := os.Getenv(EndpointEnv); e != "" { if e := os.Getenv(EndpointEnv); e != "" {
return newProxy(e) return newProxy(e)
} }
return newStatic(dir, subpath) return newStatic(dir, subpath)
} }
func newStatic(dir embed.FS, subpath string) (http.Handler, error) { func newStatic(dir fs.FS, subpath string) (http.Handler, error) {
s, err := fs.Sub(dir, subpath) s, err := fs.Sub(dir, subpath)
if err != nil { if err != nil {
return nil, err return nil, err