mod.go 564 B

1234567891011121314151617181920212223242526
  1. // mod is the entry point to all of the etcd modules.
  2. package mod
  3. import (
  4. "net/http"
  5. "path"
  6. "github.com/coreos/etcd/mod/dashboard"
  7. "github.com/gorilla/mux"
  8. )
  9. var ServeMux *http.Handler
  10. func addSlash(w http.ResponseWriter, req *http.Request) {
  11. http.Redirect(w, req, path.Join("mod", req.URL.Path) + "/", 302)
  12. return
  13. }
  14. func HttpHandler() (handler http.Handler) {
  15. modMux := mux.NewRouter()
  16. modMux.HandleFunc("/dashboard", addSlash)
  17. modMux.PathPrefix("/dashboard/").
  18. Handler(http.StripPrefix("/dashboard/", dashboard.HttpHandler()))
  19. return modMux
  20. }