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:
Daniel Smith
2014-10-27 17:54:33 -07:00
parent 4311273294
commit 7209ca1543
2 changed files with 6 additions and 1 deletions

View File

@@ -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)

View File

@@ -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,