You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
568 B
25 lines
568 B
package app |
|
|
|
import ( |
|
"embed" |
|
"io/fs" |
|
"net/http" |
|
) |
|
|
|
//go:embed web/dist |
|
var reactAppFS embed.FS |
|
|
|
// GetReactAppFS returns a http.FileSystem from the embedded React app |
|
func GetReactAppFS() http.FileSystem { |
|
webDist, err := fs.Sub(reactAppFS, "web/dist") |
|
if err != nil { |
|
panic("Failed to load embedded web app: " + err.Error()) |
|
} |
|
return http.FS(webDist) |
|
} |
|
|
|
// ServeEmbeddedWeb serves the embedded web application |
|
func ServeEmbeddedWeb(w http.ResponseWriter, r *http.Request) { |
|
// Serve the embedded web app |
|
http.FileServer(GetReactAppFS()).ServeHTTP(w, r) |
|
}
|
|
|