Re:Show HN: Goyave – Golang Web Framework
by SystemGlitch on Saturday March 28, 2020 @07:24PM
(#22715090)
Fair point. The "automatic 404 when a database record is not found" is purely optional and something you choose to use or not, like all the other helpers. For example, see below code:
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.
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.