@@ -1,6 +1,24 @@
|
||||
package outfitvotingabi26
|
||||
package assets
|
||||
|
||||
import "embed"
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
//go:embed frontend
|
||||
//go:embed frontend/dist/*
|
||||
var frontendFS embed.FS
|
||||
|
||||
func HttpServer() http.Handler {
|
||||
fs, err := fs.Sub(frontendFS, "frontend/dist")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return http.FileServerFS(fs)
|
||||
}
|
||||
|
||||
func ServeIndex(w http.ResponseWriter, r *http.Request) {
|
||||
file, _ := frontendFS.ReadFile("frontend/dist/index.html")
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
w.Write(file)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user