Move namespace from query param to path part

This commit is contained in:
derekwaynecarr
2014-12-09 14:23:21 -05:00
parent 58ba3c7faa
commit 7cf664439f
16 changed files with 388 additions and 156 deletions

View File

@@ -77,17 +77,19 @@ func isWebsocketRequest(req *http.Request) bool {
// ServeHTTP processes watch requests.
func (h *WatchHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
ctx := api.NewContext()
namespace := req.URL.Query().Get("namespace")
if len(namespace) > 0 {
ctx = api.WithNamespace(ctx, namespace)
}
parts := splitPath(req.URL.Path)
if len(parts) < 1 || req.Method != "GET" {
if req.Method != "GET" {
notFound(w, req)
return
}
storage := h.storage[parts[0]]
namespace, kind, _, err := KindAndNamespace(req)
if err != nil {
notFound(w, req)
return
}
ctx := api.WithNamespace(api.NewContext(), namespace)
storage := h.storage[kind]
if storage == nil {
notFound(w, req)
return