diff options
author | Doug Black <dblack@twilio.com> | 2014-01-26 13:42:50 -0800 |
---|---|---|
committer | Doug Black <dblack@twilio.com> | 2014-01-26 13:42:50 -0800 |
commit | 5a10edcd157f6a1d16dea18f137ae6f5a87d5001 (patch) | |
tree | 39e26745572f62c9a406038281b16879fa76834b /core.go | |
parent | fix signature (diff) | |
download | sleepy-5a10edcd157f6a1d16dea18f137ae6f5a87d5001.tar.gz sleepy-5a10edcd157f6a1d16dea18f137ae6f5a87d5001.tar.bz2 sleepy-5a10edcd157f6a1d16dea18f137ae6f5a87d5001.zip |
fixes from issues
Diffstat (limited to 'core.go')
-rw-r--r-- | core.go | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -25,6 +25,7 @@ type Api struct{} func (api *Api) Abort(rw http.ResponseWriter, statusCode int) { rw.WriteHeader(statusCode) + rw.Write([]byte(http.StatusText(statusCode))) } func (api *Api) requestHandler(resource Resource) http.HandlerFunc { @@ -54,12 +55,12 @@ func (api *Api) requestHandler(resource Resource) http.HandlerFunc { return } - responseWriter := json.NewEncoder(rw) + content, err := json.Marshal(data) + if err != nil { + api.Abort(rw, 500) + } rw.WriteHeader(code) - if responseWriter.Encode(data) != nil { - api.Abort(rw, 500) - return - } + rw.Write(content) } } |