Setting up a not found handler in utron

December 4, 2016 ยท View on GitHub

Custom rendering of 404 status page is easy in utron.

Utron App provides a method SetNotFoundHandler(h http.Handler) error which you can use it as follows.

First we define our handler function

func NotFound(w http.ResponseWriter, r *http.Request) {
	w.Write([]byte("we found nothing"))
}

And then we register it like this

	app := utron.NewApp()
	app.SetNotFoundHandler(http.HandlerFunc(NotFound))

Enjoy