|
|
- package main
-
- import (
- "embed"
- "io/fs"
- "log"
- "net/http"
-
- "git.tovijaeschke.xyz/tovi/SuddenImpactRecords/Api"
- "git.tovijaeschke.xyz/tovi/SuddenImpactRecords/Database"
-
- "github.com/gorilla/mux"
- )
-
- //go:embed Frontend/vue/dist
- var frontend embed.FS
-
- type spaHandler struct {
- staticFS embed.FS
- staticPath string
- indexPath string
- }
-
- func main() {
- var (
- router *mux.Router
- stripped fs.FS
- frontendFS http.Handler
- err error
- )
-
- Database.Init()
-
- router = Api.InitApiEndpoints()
-
- stripped, err = fs.Sub(frontend, "Frontend/vue/dist")
- if err != nil {
- log.Fatalln(err)
- }
-
- frontendFS = http.FileServer(http.FS(stripped))
- router.PathPrefix("/").Handler(frontendFS)
-
- http.ListenAndServe(":8080", router)
- }
|