Switch to single embed fs and add vue and svelte frontends
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
package reactNextJS
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
//go:embed "out/*"
|
||||
var nextFiles embed.FS
|
||||
|
||||
//go:embed "out/_next"
|
||||
var nextScripts embed.FS
|
||||
|
||||
// Call this from main once before starting the server
|
||||
func AddNextStaticClient() {
|
||||
scriptsSubFolder, err := fs.Sub(nextScripts, "out")
|
||||
if err != nil {
|
||||
panic(fmt.Sprint("Error: Could not find \"reactNextJS/out/\". Did you build the reactNextJS client?"))
|
||||
}
|
||||
filesSubFolder, _ := fs.Sub(nextFiles, "out")
|
||||
var nextScriptsServer = http.FileServerFS(scriptsSubFolder)
|
||||
var nextFilesServer = http.FileServerFS(filesSubFolder)
|
||||
|
||||
http.Handle("/reactNextJS/", http.StripPrefix("/reactNextJS/", nextFilesServer))
|
||||
http.Handle("/_next/", nextScriptsServer)
|
||||
}
|
||||
Reference in New Issue
Block a user