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.

45 lines
736 B

  1. package main
  2. import (
  3. "embed"
  4. "io/fs"
  5. "log"
  6. "net/http"
  7. "git.tovijaeschke.xyz/tovi/SuddenImpactRecords/Api"
  8. "git.tovijaeschke.xyz/tovi/SuddenImpactRecords/Database"
  9. "github.com/gorilla/mux"
  10. )
  11. //go:embed Frontend/vue/dist
  12. var frontend embed.FS
  13. type spaHandler struct {
  14. staticFS embed.FS
  15. staticPath string
  16. indexPath string
  17. }
  18. func main() {
  19. var (
  20. router *mux.Router
  21. stripped fs.FS
  22. frontendFS http.Handler
  23. err error
  24. )
  25. Database.Init()
  26. router = Api.InitApiEndpoints()
  27. stripped, err = fs.Sub(frontend, "Frontend/vue/dist")
  28. if err != nil {
  29. log.Fatalln(err)
  30. }
  31. frontendFS = http.FileServer(http.FS(stripped))
  32. router.PathPrefix("/").Handler(frontendFS)
  33. http.ListenAndServe(":8080", router)
  34. }