func MyHandler(w http.ResponseWriter, r *http.Request) { // do some logic here if err != nil { middleware.RenderWithErr(w, r, http.StatusNotFound, "Page not found") return } // handle success case }
func AnotherHandler(w http.ResponseWriter, r *http.Request) { // do some logic here if err != nil { middleware.RenderWithErr(w, r, http.StatusInternalServerError, "Something went wrong") return } // handle success case }Overall, the "Context" middleware in the "github.com/gogits/gogs/modules/middleware" library provides helpful functions to render error messages to the user with specific HTTP status codes.