From d2b9f80a03e2b945f3ed45444458bacc85ec6b50 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 11 Jun 2011 09:29:41 -0700 Subject: [PATCH] send error response JSON --- lib/go/camli/search/handler.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/go/camli/search/handler.go b/lib/go/camli/search/handler.go index c7a0d639a..e022251f3 100644 --- a/lib/go/camli/search/handler.go +++ b/lib/go/camli/search/handler.go @@ -181,9 +181,12 @@ func (sh *searchHandler) serveClaims(rw http.ResponseWriter, req *http.Request) func (sh *searchHandler) serveDescribe(rw http.ResponseWriter, req *http.Request) { ret := jsonMap() + defer httputil.ReturnJson(rw, ret) + br := blobref.Parse(req.FormValue("blobref")) if br == nil { - http.Error(rw, "Missing or invalid 'blobref' param", 400) + ret["error"] = "Missing or invalid 'blobref' param" + ret["errorType"] = "input" return } @@ -213,8 +216,6 @@ func (sh *searchHandler) serveDescribe(rw http.ResponseWriter, req *http.Request } } } - - httputil.ReturnJson(rw, ret) } func (sh *searchHandler) serveFiles(rw http.ResponseWriter, req *http.Request) {