Fix pathing with relative non-single-depth root

This commit is contained in:
Bel LaPointe
2019-11-14 11:14:57 -07:00
parent 7964518d36
commit e6f63a578f
4 changed files with 100 additions and 35 deletions

View File

@@ -12,6 +12,10 @@ func (s *Server) Routes() error {
path string
handler http.HandlerFunc
}{
{
path: "/",
handler: s.root,
},
{
path: fmt.Sprintf("notes/%s%s", wildcard, wildcard),
handler: s.authenticate(s.notes),
@@ -37,3 +41,8 @@ func (s *Server) Routes() error {
}
return nil
}
func (s *Server) root(w http.ResponseWriter, r *http.Request) {
r.URL.Path = "/notes"
http.Redirect(w, r, r.URL.String(), http.StatusPermanentRedirect)
}