Enable dev assets mode with PGWEB_ASSETS_DEVMODE env var
This commit is contained in:
@@ -1,7 +1,22 @@
|
||||
package static
|
||||
|
||||
import "embed"
|
||||
import (
|
||||
"embed"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
//go:embed img/* js/* css/* fonts/*
|
||||
//go:embed index.html
|
||||
var Static embed.FS
|
||||
var assets embed.FS
|
||||
|
||||
func GetFilesystem() http.FileSystem {
|
||||
if os.Getenv("PGWEB_ASSETS_DEVMODE") == "1" {
|
||||
return http.Dir("./static")
|
||||
}
|
||||
return http.FS(assets)
|
||||
}
|
||||
|
||||
func GetHandler() http.Handler {
|
||||
return http.FileServer(GetFilesystem())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user