aboutsummaryrefslogtreecommitdiff
path: root/core.go
diff options
context:
space:
mode:
authorDoug Black <dblack@twilio.com>2014-01-26 09:31:03 -0800
committerDoug Black <dblack@twilio.com>2014-01-26 09:31:03 -0800
commitf20e28cf6057f85316d3241346d88f500cca2adc (patch)
tree61af163ad2588e6c8d24d6286646c16aeaae3aa8 /core.go
parentcleaner (diff)
downloadsleepy-f20e28cf6057f85316d3241346d88f500cca2adc.tar.gz
sleepy-f20e28cf6057f85316d3241346d88f500cca2adc.tar.bz2
sleepy-f20e28cf6057f85316d3241346d88f500cca2adc.zip
fixes from comments
Diffstat (limited to 'core.go')
-rw-r--r--core.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/core.go b/core.go
index 8647d8b..cf34545 100644
--- a/core.go
+++ b/core.go
@@ -15,10 +15,10 @@ const (
)
type Resource interface {
- Get(values ...url.Values) (int, interface{})
- Post(values ...url.Values) (int, interface{})
- Put(values ...url.Values) (int, interface{})
- Delete(values ...url.Values) (int, interface{})
+ Get(values url.Values) (int, interface{})
+ Post(values url.Values) (int, interface{})
+ Put(values url.Values) (int, interface{})
+ Delete(values url.Values) (int, interface{})
}
type Api struct{}
@@ -56,14 +56,12 @@ func (api *Api) requestHandler(resource Resource) HandleFunc {
return
}
- content, err := json.Marshal(data)
- if err != nil {
- api.Abort(rw, 500)
- return
- }
-
+ responseWriter := json.NewEncoder(rw)
rw.WriteHeader(code)
- rw.Write(content)
+ if responseWriter.Encode(data) != nil {
+ api.Abort(rw, 500)
+ return
+ }
}
}
bgstack15