mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-12 12:48:51 +00:00
Make redirect handle namespaces just like proxy (which is weird and needs to be fixed but at least this will be consistent).
This commit is contained in:
@@ -30,7 +30,11 @@ type RedirectHandler struct {
|
||||
}
|
||||
|
||||
func (r *RedirectHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
ctx := api.NewContext()
|
||||
ctx := api.NewDefaultContext()
|
||||
namespace := req.URL.Query().Get("namespace")
|
||||
if len(namespace) > 0 {
|
||||
ctx = api.WithNamespace(ctx, namespace)
|
||||
}
|
||||
parts := splitPath(req.URL.Path)
|
||||
if len(parts) != 2 || req.Method != "GET" {
|
||||
notFound(w, req)
|
||||
|
@@ -27,6 +27,7 @@ import (
|
||||
func TestRedirect(t *testing.T) {
|
||||
simpleStorage := &SimpleRESTStorage{
|
||||
errors: map[string]error{},
|
||||
expectedResourceNamespace: "default",
|
||||
}
|
||||
handler := Handle(map[string]RESTStorage{
|
||||
"foo": simpleStorage,
|
||||
|
Reference in New Issue
Block a user