Browse Source

Merge pull request #324 from philips/redirect-mod-dashboard-trailing-slash

fix(mod): redirect dashboard to /dashboard
Brandon Philips 12 years ago
parent
commit
0ed3509ec1
1 changed files with 8 additions and 0 deletions
  1. 8 0
      mod/mod.go

+ 8 - 0
mod/mod.go

@@ -3,6 +3,7 @@ package mod
 
 
 import (
 import (
 	"net/http"
 	"net/http"
+	"path"
 
 
 	"github.com/coreos/etcd/mod/dashboard"
 	"github.com/coreos/etcd/mod/dashboard"
 	"github.com/gorilla/mux"
 	"github.com/gorilla/mux"
@@ -10,9 +11,16 @@ import (
 
 
 var ServeMux *http.Handler
 var ServeMux *http.Handler
 
 
+func addSlash(w http.ResponseWriter, req *http.Request) {
+	http.Redirect(w, req, path.Join("mod", req.URL.Path) + "/", 302)
+	return
+}
+
 func HttpHandler() (handler http.Handler) {
 func HttpHandler() (handler http.Handler) {
 	modMux := mux.NewRouter()
 	modMux := mux.NewRouter()
+	modMux.HandleFunc("/dashboard", addSlash)
 	modMux.PathPrefix("/dashboard/").
 	modMux.PathPrefix("/dashboard/").
 		Handler(http.StripPrefix("/dashboard/", dashboard.HttpHandler()))
 		Handler(http.StripPrefix("/dashboard/", dashboard.HttpHandler()))
+
 	return modMux
 	return modMux
 }
 }