Skip to content

Commit 1ad37ae

Browse files
committed
Fixed crud example
Signed-off-by: Vishal Rana <[email protected]>
1 parent a4375c4 commit 1ad37ae

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

examples/crud/server.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,34 @@ var (
2424
// Handlers
2525
//----------
2626

27-
func createUser(c *echo.Context) *echo.HTTPError {
27+
func createUser(c *echo.Context) error {
2828
u := &user{
2929
ID: seq,
3030
}
31-
if he := c.Bind(u); he != nil {
32-
return he
31+
if err := c.Bind(u); err != nil {
32+
return err
3333
}
3434
users[u.ID] = u
3535
seq++
3636
return c.JSON(http.StatusCreated, u)
3737
}
3838

39-
func getUser(c *echo.Context) *echo.HTTPError {
39+
func getUser(c *echo.Context) error {
4040
id, _ := strconv.Atoi(c.Param("id"))
4141
return c.JSON(http.StatusOK, users[id])
4242
}
4343

44-
func updateUser(c *echo.Context) *echo.HTTPError {
44+
func updateUser(c *echo.Context) error {
4545
u := new(user)
46-
if he := c.Bind(u); he != nil {
47-
return he
46+
if err := c.Bind(u); err != nil {
47+
return err
4848
}
4949
id, _ := strconv.Atoi(c.Param("id"))
5050
users[id].Name = u.Name
5151
return c.JSON(http.StatusOK, users[id])
5252
}
5353

54-
func deleteUser(c *echo.Context) *echo.HTTPError {
54+
func deleteUser(c *echo.Context) error {
5555
id, _ := strconv.Atoi(c.Param("id"))
5656
delete(users, id)
5757
return c.NoContent(http.StatusNoContent)

0 commit comments

Comments
 (0)