title: Setting up Route Not Found in Gin
body: <p>I've setup a default router and some routes in Gin:</p>
  
  <pre><code>router := gin.Default()
  router.POST("/users", save)
  router.GET("/users",getAll)
  </code></pre>
  
  <p>but how do I handle 404 Route Not Found in Gin?</p>
  
  <p>Originally, I was using httprouter which I understand Gin uses so this was what I originally had...</p>
  
  <pre><code>router.NotFound = http.HandlerFunc(customNotFound)
  </code></pre>
  
  <p>and the function:</p>
  
  <pre><code>func customNotFound(w http.ResponseWriter, r *http.Request) {
      //return JSON
      return
  }
  </code></pre>
  
  <p>but this won't work with Gin.</p>
  
  <p>I need to be able to return JSON using the <code>c *gin.Context</code> so that I can use:</p>
  
  <pre><code>c.JSON(404, gin.H{"code": "PAGE_NOT_FOUND", "message": "Page not found"})
  </code></pre>