binding.go
func ErrorHandler(errs Errors, resp http.ResponseWriter) {
	if len(errs) > 0 {
		resp.Header().Set("Content-Type", jsonContentType)
		if errs.Has(DeserializationError) {
			resp.WriteHeader(http.StatusBadRequest)
		} else if errs.Has(ContentTypeError) {
			resp.WriteHeader(http.StatusUnsupportedMediaType)
		} else {
			resp.WriteHeader(StatusUnprocessableEntity)
		}
		errOutput, _ := json.Marshal(errs)
		resp.Write(errOutput)
		return
	}
}
func ErrorHandler(errs Errors, resp http.ResponseWriter) {
	if len(errs) > 0 {
		resp.Header().Set("Content-Type", jsonContentType)
		if errs.Has(DeserializationError) {
			resp.WriteHeader(http.StatusBadRequest)
		} else if errs.Has(ContentTypeError) {
			resp.WriteHeader(http.StatusUnsupportedMediaType)
		} else {
			resp.WriteHeader(StatusUnprocessableEntity)
		}
		errOutput, _ := json.Marshal(errs)
		resp.Write(errOutput)
		return
	}
}
func ErrorHandler ( errs Errors , resp http . ResponseWriter ) { if len ( errs ) > 0 { resp . Header ( ) . Set ( " " , jsonContentType ) if errs . Has ( DeserializationError ) { resp . WriteHeader ( http . StatusBadRequest ) } else if errs . Has ( ContentTypeError ) { resp . WriteHeader ( http . StatusUnsupportedMediaType ) } else { resp . WriteHeader ( StatusUnprocessableEntity ) } errOutput , _ := json . Marshal ( errs ) resp . Write ( errOutput ) return } }
// ErrorHandler simply counts the number of errors in the
// context and, if more than 0, writes a response with an
// error code and a JSON payload describing the errors.
// The response will have a JSON content-type.
// Middleware remaining on the stack will not even see the request
// if, by this point, there are any errors.
// This is a "default" handler, of sorts, and you are
// welcome to use your own instead. The Bind middleware
// invokes this automatically for convenience.
ErrorHandler simply counts the number of errors in the context and if more than 0 writes a response with an error code and a JSON payload describing the errors . The response will have a JSON content - type . Middleware remaining on the stack will not even see the request if by this point there are any errors . This is a default handler of sorts and you are welcome to use your own instead . The Bind middleware invokes this automatically for convenience .