func createUser(c *echo.Context) error { u := new(user) if err := c.Bind(u); err != nil { return err } users[u.ID] = *u return c.JSON(http.StatusCreated, u) }
func updateUser(c *echo.Context) error { u := new(user) if err := c.Bind(u); err != nil { return err } id, _ := strconv.Atoi(c.Param("id")) users[id].Name = u.Name return c.JSON(http.StatusOK, users[id]) }
func createUser(c *echo.Context) error { u := &user{ ID: seq, } if err := c.Bind(u); err != nil { return err } users[u.ID] = u seq++ return c.JSON(http.StatusCreated, u) }
func getUser(c *echo.Context) error { id, _ := strconv.Atoi(c.Param("id")) return c.JSON(http.StatusOK, users[id]) }
func getUser(c *echo.Context) error { return c.JSON(http.StatusOK, users[c.P(0)]) }
func getUsers(c *echo.Context) error { return c.JSON(http.StatusOK, users) }