Switch LogOf from panicking when logger is missing to creating logger with the defaults.

Update CORS tests to a table-based test and cover more cases.
This commit is contained in:
Jessica Forrester
2014-09-09 17:05:18 -04:00
parent becf6ca4e7
commit 0cac1c5f79
7 changed files with 85 additions and 92 deletions

View File

@@ -42,7 +42,7 @@ func (h *RESTHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
}
storage := h.storage[parts[0]]
if storage == nil {
httplog.FindOrCreateLogOf(req, &w).Addf("'%v' has no storage object", parts[0])
httplog.LogOf(req, w).Addf("'%v' has no storage object", parts[0])
notFound(w, req)
return
}
@@ -114,7 +114,7 @@ func (h *RESTHandler) handleRESTStorage(parts []string, req *http.Request, w htt
return
}
op := h.createOperation(out, sync, timeout)
h.finishReq(op, w)
h.finishReq(op, req, w)
case "DELETE":
if len(parts) != 2 {
@@ -127,7 +127,7 @@ func (h *RESTHandler) handleRESTStorage(parts []string, req *http.Request, w htt
return
}
op := h.createOperation(out, sync, timeout)
h.finishReq(op, w)
h.finishReq(op, req, w)
case "PUT":
if len(parts) != 2 {
@@ -151,7 +151,7 @@ func (h *RESTHandler) handleRESTStorage(parts []string, req *http.Request, w htt
return
}
op := h.createOperation(out, sync, timeout)
h.finishReq(op, w)
h.finishReq(op, req, w)
default:
notFound(w, req)
@@ -171,7 +171,7 @@ func (h *RESTHandler) createOperation(out <-chan runtime.Object, sync bool, time
// finishReq finishes up a request, waiting until the operation finishes or, after a timeout, creating an
// Operation to receive the result and returning its ID down the writer.
func (h *RESTHandler) finishReq(op *Operation, w http.ResponseWriter) {
func (h *RESTHandler) finishReq(op *Operation, req *http.Request, w http.ResponseWriter) {
obj, complete := op.StatusOrResult()
if complete {
status := http.StatusOK