Hacker News new | ask | show | jobs
by SystemGlitch 2270 days ago
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.