@@ -31,20 +31,17 @@ func (c *Context) Param(n string) string {
3131}
3232
3333// Bind decodes the payload into provided type based on Content-Type header.
34- func (c * Context ) Bind (i interface {}) bool {
35- var err error
34+ func (c * Context ) Bind (i interface {}) (err error ) {
3635 ct := c .Request .Header .Get (HeaderContentType )
3736 if strings .HasPrefix (ct , MIMEJSON ) {
3837 dec := json .NewDecoder (c .Request .Body )
39- err = dec .Decode (i )
38+ if err = dec .Decode (i ); err != nil {
39+ err = ErrBindJSON
40+ }
4041 } else {
41- // TODO:
42+ err = ErrUnsupportedContentType
4243 }
43- if err != nil {
44- c .echo .internalServerErrorHandler (c )
45- return false
46- }
47- return true
44+ return
4845}
4946
5047// String sends a text/plain response with status code.
@@ -55,13 +52,14 @@ func (c *Context) String(n int, s string) {
5552}
5653
5754// JSON sends an application/json response with status code.
58- func (c * Context ) JSON (n int , i interface {}) {
55+ func (c * Context ) JSON (n int , i interface {}) ( err error ) {
5956 enc := json .NewEncoder (c .Response )
6057 c .Response .Header ().Set (HeaderContentType , MIMEJSON + "; charset=utf-8" )
6158 c .Response .WriteHeader (n )
6259 if err := enc .Encode (i ); err != nil {
63- c . echo . internalServerErrorHandler ( c )
60+ err = ErrRenderJSON
6461 }
62+ return
6563}
6664
6765// func (c *Context) File(n int, file, name string) {
0 commit comments