WithErrorHandlers registers additional error handlers to be used while rendering errors.
(h map[string]http.Handler)
| 68 | |
| 69 | // WithErrorHandlers registers additional error handlers to be used while rendering errors. |
| 70 | func WithErrorHandlers(h map[string]http.Handler) func(http.Handler) http.Handler { |
| 71 | return func(next http.Handler) http.Handler { |
| 72 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 73 | r = r.WithContext(context.WithValue(r.Context(), errorHandlersKey, h)) |
| 74 | next.ServeHTTP(w, r) |
| 75 | }) |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | type errorKeyType struct{} |
| 80 |
no test coverage detected