site/src/router/router.go
2024-11-27 14:20:48 -05:00

43 lines
1.2 KiB
Go

package router
import (
"net/http"
"dofdev/web/pages/about"
braillexr "dofdev/web/pages/braille_xr"
"dofdev/web/pages/dev"
"dofdev/web/pages/games"
"dofdev/web/pages/mono"
"dofdev/web/pages/moves"
"dofdev/web/pages/projects"
"dofdev/web/pages/sc"
"github.com/gorilla/mux"
)
func New() *mux.Router {
r := mux.NewRouter() // .StrictSlash(false)
r.PathPrefix(("/public/")).Handler(http.StripPrefix("/public/", http.FileServer(http.Dir("web/public/"))))
r.HandleFunc("/", mono.Handler)
r.HandleFunc("/about", about.Handler)
r.HandleFunc("/dev", dev.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("/game/{hash}/privacy", games.PrivacyHandler)
r.HandleFunc("/projects", projects.Handler)
r.HandleFunc("/project/{hash}", projects.ProjectHandler)
r.HandleFunc("/sc", sc.Handler)
r.HandleFunc("/braille_xr", braillexr.Handler)
// r.HandleFunc("/reload", func(w http.ResponseWriter, r *http.Request) {
// tem.Load()
// // route them back to where they came from
// http.Redirect(w, r, r.Header.Get("Referer"), http.StatusFound)
// })
return r
}