Created
October 4, 2019 08:55
-
-
Save sumanentc/4aa256df56efcd0c8c93a8c1a88e306e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func AddCat(c echo.Context) error { | |
type Cat struct { | |
Name string `json:"name"` | |
Type string `json:"type"` | |
} | |
cat := Cat{} | |
defer c.Request().Body.Close() | |
err := json.NewDecoder(c.Request().Body).Decode(&cat) | |
if err != nil { | |
log.Fatalf("Failed reading the request body %s", err) | |
return echo.NewHTTPError(http.StatusInternalServerError, err.Error) | |
} | |
log.Printf("this is yout cat %#v", cat) | |
return c.String(http.StatusOK, "We got your Cat!!!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment