route pages

This commit is contained in:
ethan merchant 2024-11-03 02:46:55 -05:00
parent c40f003590
commit 4a5f23da84

View file

@ -3,10 +3,15 @@ package router
import ( import (
"net/http" "net/http"
"dofdev/web/pages/about"
braillexr "dofdev/web/pages/braille_xr"
"dofdev/web/pages/games"
"dofdev/web/pages/mono"
"dofdev/web/pages/moves"
"dofdev/web/pages/projects"
"dofdev/web/pages/sc"
"github.com/gorilla/mux" "github.com/gorilla/mux"
braillexr "github.com/spatialfree/dofdev/web/pages/braille_xr"
"github.com/spatialfree/dofdev/web/pages/mono"
"github.com/spatialfree/dofdev/tem"
) )
func New() *mux.Router { func New() *mux.Router {
@ -14,12 +19,22 @@ func New() *mux.Router {
r.PathPrefix(("/public/")).Handler(http.StripPrefix("/public/", http.FileServer(http.Dir("web/public/")))) r.PathPrefix(("/public/")).Handler(http.StripPrefix("/public/", http.FileServer(http.Dir("web/public/"))))
r.HandleFunc("/", mono.Handler) r.HandleFunc("/", mono.Handler)
r.HandleFunc("/about", about.Handler)
r.HandleFunc("/moves", moves.Handler)
r.HandleFunc("/move/{hash}", moves.MoveHandler)
r.HandleFunc("/games", games.Handler)
r.HandleFunc("/game/{hash}", games.GameHandler)
r.HandleFunc("/projects", projects.Handler)
r.HandleFunc("/project/{hash}", projects.ProjectHandler)
r.HandleFunc("/sc", sc.Handler)
r.HandleFunc("/braille_xr", braillexr.Handler) r.HandleFunc("/braille_xr", braillexr.Handler)
r.HandleFunc("/reload", func(w http.ResponseWriter, r *http.Request) { // r.HandleFunc("/reload", func(w http.ResponseWriter, r *http.Request) {
tem.Load() // tem.Load()
// route them back to where they came from // // route them back to where they came from
http.Redirect(w, r, r.Header.Get("Referer"), http.StatusFound) // http.Redirect(w, r, r.Header.Get("Referer"), http.StatusFound)
}) // })
return r return r
} }