2014-10-07 16:44:22 +00:00
|
|
|
/*
|
2016-06-03 00:25:58 +00:00
|
|
|
Copyright 2014 The Kubernetes Authors.
|
2014-10-07 16:44:22 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2016-09-06 11:20:36 +00:00
|
|
|
package routes
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2017-02-02 09:25:56 +00:00
|
|
|
"k8s.io/apiserver/pkg/server/mux"
|
2016-09-06 11:20:36 +00:00
|
|
|
)
|
|
|
|
|
2017-01-09 21:17:23 +00:00
|
|
|
const dashboardPath = "/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy"
|
2016-09-06 11:20:36 +00:00
|
|
|
|
2017-10-11 14:16:03 +00:00
|
|
|
// UIRedirect redirects /ui to the kube-ui proxy path.
|
2016-09-06 11:20:36 +00:00
|
|
|
type UIRedirect struct{}
|
|
|
|
|
2017-03-10 13:10:53 +00:00
|
|
|
func (r UIRedirect) Install(c *mux.PathRecorderMux) {
|
2017-04-13 19:25:17 +00:00
|
|
|
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
2016-09-06 11:20:36 +00:00
|
|
|
http.Redirect(w, r, dashboardPath, http.StatusTemporaryRedirect)
|
|
|
|
})
|
2017-04-13 19:25:17 +00:00
|
|
|
c.Handle("/ui", handler)
|
|
|
|
c.HandlePrefix("/ui/", handler)
|
2016-09-06 11:20:36 +00:00
|
|
|
}
|