@@ -9,14 +9,14 @@ Echo is a fast HTTP router (zero memory allocation) and micro web framework in G
99 - `echo.MiddlewareFunc`
1010 - `func(echo.HandlerFunc) echo.HandlerFunc`
1111 - `echo.HandlerFunc`
12- - `func(*echo.Context) *echo.HTTPError `
12+ - `func(*echo.Context) error `
1313 - `func(http.Handler) http.Handler`
1414 - `http.Handler`
1515 - `http.HandlerFunc`
1616 - `func(http.ResponseWriter, *http.Request)`
1717 - Handler
1818 - `echo.HandlerFunc`
19- - `func(*echo.Context) *echo.HTTPError `
19+ - `func(*echo.Context) error `
2020 - `http.Handler`
2121 - `http.HandlerFunc`
2222 - `func(http.ResponseWriter, *http.Request)`
@@ -84,7 +84,7 @@ import (
8484)
8585
8686// Handler
87- func hello (c *echo .Context ) * echo . HTTPError {
87+ func hello (c *echo .Context ) error {
8888 return c.String (http.StatusOK , " Hello, World!\n " )
8989}
9090
@@ -133,34 +133,34 @@ var (
133133// Handlers
134134// ----------
135135
136- func createUser (c *echo .Context ) * echo . HTTPError {
136+ func createUser (c *echo .Context ) error {
137137 u := &user{
138138 ID: seq,
139139 }
140- if he := c.Bind (u); he != nil {
141- return he
140+ if err := c.Bind (u); err != nil {
141+ return err
142142 }
143143 users[u.ID ] = u
144144 seq++
145145 return c.JSON (http.StatusCreated , u)
146146}
147147
148- func getUser (c *echo .Context ) * echo . HTTPError {
148+ func getUser (c *echo .Context ) error {
149149 id , _ := strconv.Atoi (c.Param (" id" ))
150150 return c.JSON (http.StatusOK , users[id])
151151}
152152
153- func updateUser (c *echo .Context ) * echo . HTTPError {
153+ func updateUser (c *echo .Context ) error {
154154 u := new (user)
155- if he := c.Bind (u); he != nil {
156- return he
155+ if err := c.Bind (u); err != nil {
156+ return err
157157 }
158158 id , _ := strconv.Atoi (c.Param (" id" ))
159159 users[id].Name = u.Name
160160 return c.JSON (http.StatusOK , users[id])
161161}
162162
163- func deleteUser (c *echo .Context ) * echo . HTTPError {
163+ func deleteUser (c *echo .Context ) error {
164164 id , _ := strconv.Atoi (c.Param (" id" ))
165165 delete (users, id)
166166 return c.NoContent (http.StatusNoContent )
@@ -218,22 +218,19 @@ var (
218218)
219219
220220// Render HTML
221- func (t *Template ) Render (w io .Writer , name string , data interface {}) *echo .HTTPError {
222- if err := t.templates .ExecuteTemplate (w, name, data); err != nil {
223- return &echo.HTTPError {Error: err}
224- }
225- return nil
221+ func (t *Template ) Render (w io .Writer , name string , data interface {}) error {
222+ return t.templates .ExecuteTemplate (w, name, data)
226223}
227224
228225// ----------
229226// Handlers
230227// ----------
231228
232- func welcome (c *echo .Context ) * echo . HTTPError {
229+ func welcome (c *echo .Context ) error {
233230 return c.Render (http.StatusOK , " welcome" , " Joe" )
234231}
235232
236- func createUser (c *echo .Context ) * echo . HTTPError {
233+ func createUser (c *echo .Context ) error {
237234 u := new (user)
238235 if err := c.Bind (u); err != nil {
239236 return err
@@ -242,11 +239,11 @@ func createUser(c *echo.Context) *echo.HTTPError {
242239 return c.JSON (http.StatusCreated , u)
243240}
244241
245- func getUsers (c *echo .Context ) * echo . HTTPError {
242+ func getUsers (c *echo .Context ) error {
246243 return c.JSON (http.StatusOK , users)
247244}
248245
249- func getUser (c *echo .Context ) * echo . HTTPError {
246+ func getUser (c *echo .Context ) error {
250247 return c.JSON (http.StatusOK , users[c.P (0 )])
251248}
252249
@@ -268,7 +265,7 @@ func main() {
268265 s := stats.New ()
269266 e.Use (s.Handler )
270267 // Route
271- e.Get (" /stats" , func (c *echo.Context ) *echo. HTTPError {
268+ e.Get (" /stats" , func (c *echo.Context ) error {
272269 return c.JSON (http.StatusOK , s.Data ())
273270 })
274271
@@ -297,7 +294,7 @@ func main() {
297294 // Cached templates
298295 templates: template.Must (template.ParseFiles (" public/views/welcome.html" )),
299296 }
300- e.Renderer (t)
297+ e.SetRenderer (t)
301298 e.Get (" /welcome" , welcome)
302299
303300 // -------
@@ -306,20 +303,20 @@ func main() {
306303
307304 // Group with parent middleware
308305 a := e.Group (" /admin" )
309- a.Use (func (c *echo.Context ) *echo. HTTPError {
306+ a.Use (func (c *echo.Context ) error {
310307 // Security middleware
311308 return nil
312309 })
313- a.Get (" " , func (c *echo.Context ) *echo. HTTPError {
310+ a.Get (" " , func (c *echo.Context ) error {
314311 return c.String (http.StatusOK , " Welcome admin!" )
315312 })
316313
317314 // Group with no parent middleware
318- g := e.Group (" /files" , func (c *echo.Context ) *echo. HTTPError {
315+ g := e.Group (" /files" , func (c *echo.Context ) error {
319316 // Security middleware
320317 return nil
321318 })
322- g.Get (" " , func (c *echo.Context ) *echo. HTTPError {
319+ g.Get (" " , func (c *echo.Context ) error {
323320 return c.String (http.StatusOK , " Your files!" )
324321 })
325322
@@ -350,7 +347,7 @@ import (
350347)
351348
352349// Handler
353- func hello (c *echo .Context ) * echo . HTTPError {
350+ func hello (c *echo .Context ) error {
354351 return c.String (http.StatusOK , " Hello, World!\n " )
355352}
356353
@@ -359,7 +356,7 @@ func main() {
359356 e := echo.New ()
360357
361358 // Debug mode
362- e.Debug (true )
359+ e.SetDebug (true )
363360
364361 // ------------
365362 // Middleware
0 commit comments