Skip to content

Commit

Permalink
start normalizing error handling in watch.
Browse files Browse the repository at this point in the history
  • Loading branch information
brendandburns committed Mar 18, 2015
1 parent 4725eca commit 6d763dc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/apiserver/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package apiserver

import (
"fmt"
"net/http"
"path"
"regexp"
Expand Down Expand Up @@ -69,24 +70,23 @@ func (h *WatchHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
defer monitor("watch", &verb, &apiResource, &httpCode, reqStart)

if req.Method != "GET" {
notFound(w, req)
httpCode = http.StatusNotFound
httpCode = errorJSON(errors.NewBadRequest(
fmt.Sprintf("unsupported method for watch: %s", req.Method)), h.codec, w)
return
}

requestInfo, err := h.info.GetAPIRequestInfo(req)
if err != nil {
notFound(w, req)
httpCode = http.StatusNotFound
httpCode = errorJSON(errors.NewBadRequest(
fmt.Sprintf("failed to find api request info: %s", err.Error())), h.codec, w)
return
}
verb = requestInfo.Verb
ctx := api.WithNamespace(api.NewContext(), requestInfo.Namespace)

storage := h.storage[requestInfo.Resource]
if storage == nil {
notFound(w, req)
httpCode = http.StatusNotFound
httpCode = errorJSON(errors.NewNotFound(requestInfo.Resource, "Resource"), h.codec, w)
return
}
apiResource = requestInfo.Resource
Expand Down

0 comments on commit 6d763dc

Please sign in to comment.