Copyright 2019 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

package middleware

import (
	
	

	
	
	
)
ErrorReporting returns a middleware that reports any server errors using the report func.
Don't report if the bypass header was set.
			if .bypass {
				return
Don't report success or client errors.
			if .status < 500 {
				return
Don't report 503s; they are a normal consequence of load shedding.
Don't report errors where the proxy times out; they're too common.
Don't report on proxy internal errors; they're not actionable.
			if .status == derrors.ToStatus(derrors.ProxyError) {
				return
			}
			(errorreporting.Entry{
				Error: fmt.Errorf("handler for %q returned status code %d", .URL.Path, .status),
				Req:   ,
			})
		})
	}
}

type erResponseWriter struct {
	http.ResponseWriter

	bypass bool
	status int
}

func ( *erResponseWriter) ( int) {
	.status = 
	if .ResponseWriter.Header().Get(config.BypassErrorReportingHeader) == "true" {
Don't send this header to clients.