Revision b22c6fed4db9e4011dda1d8fe3bca01debc11357 authored by Alex Polvi on 05 December 2013, 18:07:51 UTC, committed by Alex Polvi on 05 December 2013, 18:07:51 UTC
1 parent 618def7
Raw File
mod.go
// mod is the entry point to all of the etcd modules.
package mod

import (
	"net/http"
	"path"

	"github.com/coreos/etcd/mod/dashboard"
	"github.com/gorilla/mux"
)

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) {
	modMux := mux.NewRouter()
	modMux.HandleFunc("/dashboard", addSlash)
	modMux.PathPrefix("/dashboard/").
		Handler(http.StripPrefix("/dashboard/", dashboard.HttpHandler()))

	return modMux
}
back to top