by TXV · 6y ago · 0 comments
But sure, if you want to get a server up and running from scratch very quickly for a POC or a simple API-over-a-database app, this lib might be a good starting point.
func Show(response *goyave.Response, request *goyave.Request) {
product := model.Product{}
id, _ := strconv.ParseUint(request.Params["id"], 10, 64)
result := database.GetConnection().First(&product, id)
if response.HandleDatabaseError(result) {
response.JSON(http.StatusOK, product)
}
}
"response.HandleDatabaseError" is the helper we're talking about.