Fixup apiserver proxy to be namespace aware

This commit is contained in:
derekwaynecarr
2014-10-17 15:08:24 -04:00
parent d5377e4a39
commit 5e01c804fd
2 changed files with 10 additions and 1 deletions

View File

@@ -77,7 +77,14 @@ type ProxyHandler struct {
}
func (r *ProxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
ctx := api.NewContext()
// use the default namespace to address the service
ctx := api.NewDefaultContext()
// if not in default namespace, provide the query parameter
// TODO this will need to go in the path in the future and not as a query parameter
namespace := req.URL.Query().Get("namespace")
if len(namespace) > 0 {
ctx = api.WithNamespace(ctx, namespace)
}
parts := strings.SplitN(req.URL.Path, "/", 3)
if len(parts) < 2 {
notFound(w, req)