Make genericapiserver handler chain customizable

This commit is contained in:
Dr. Stefan Schimanski
2016-09-28 11:26:50 +02:00
committed by deads2k
parent 7cfd0150e4
commit 68cee1d9ac
18 changed files with 269 additions and 171 deletions

View File

@@ -19,9 +19,7 @@ package routes
import (
"net/http"
"github.com/emicklei/go-restful"
"k8s.io/kubernetes/pkg/apiserver"
"k8s.io/kubernetes/pkg/genericapiserver/mux"
)
const dashboardPath = "/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard"
@@ -29,8 +27,8 @@ const dashboardPath = "/api/v1/proxy/namespaces/kube-system/services/kubernetes-
// UIRediect redirects /ui to the kube-ui proxy path.
type UIRedirect struct{}
func (r UIRedirect) Install(mux *apiserver.PathRecorderMux, c *restful.Container) {
mux.HandleFunc("/ui/", func(w http.ResponseWriter, r *http.Request) {
func (r UIRedirect) Install(c *mux.APIContainer) {
c.NonSwaggerRoutes.HandleFunc("/ui/", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, dashboardPath, http.StatusTemporaryRedirect)
})
}