send error response JSON

This commit is contained in:
Brad Fitzpatrick 2011-06-11 09:29:41 -07:00
parent 9524e16795
commit d2b9f80a03
1 changed files with 4 additions and 3 deletions

View File

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