func init() {
	render.Respond = func(w http.ResponseWriter, r *http.Request, v interface{}) {
		if err, ok := v.(error); ok {

			// We set a default error status response code if one hasn't been set.
			if _, ok := r.Context().Value(render.StatusCtxKey).(int); !ok {
				w.WriteHeader(400)
			}

			// We log the error
			fmt.Printf("Logging err: %s\n", err.Error())

			// We change the response to not reveal the actual error message,
			// instead we can transform the message something more friendly or mapped
			// to some code / language, etc.
			render.DefaultResponder(w, r, render.M{"status": "error"})
			return
		}

		render.DefaultResponder(w, r, v)
	}
}
func init() {
	render.Respond = func(w http.ResponseWriter, r *http.Request, v interface{}) {
		if err, ok := v.(error); ok {

			// We set a default error status response code if one hasn't been set.
			if _, ok := r.Context().Value(render.StatusCtxKey).(int); !ok {
				w.WriteHeader(400)
			}

			// We log the error
			fmt.Printf("Logging err: %s\n", err.Error())

			// We change the response to not reveal the actual error message,
			// instead we can transform the message something more friendly or mapped
			// to some code / language, etc.
			render.DefaultResponder(w, r, render.M{"status": "error"})
			return
		}

		render.DefaultResponder(w, r, v)
	}
}
func init ( ) { render . Respond = func ( w http . ResponseWriter , r * http . Request , v interface { } ) { if err , ok := v . ( error ) ; ok { // We set a default error status response code if one hasn't been set. if _ , ok := r . Context ( ) . Value ( render . StatusCtxKey ) . ( int ) ; ! ok { w . WriteHeader ( 400 ) } // We log the error fmt . Printf ( " \n " , err . Error ( ) ) // We change the response to not reveal the actual error message, // instead we can transform the message something more friendly or mapped // to some code / language, etc. render . DefaultResponder ( w , r , render . M { " " : " " } ) return } render . DefaultResponder ( w , r , v ) } }
// This is entirely optional, but I wanted to demonstrate how you could easily
// add your own logic to the render.Respond method.
This is entirely optional but I wanted to demonstrate how you could easily add your own logic to the render . Respond method .