MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / WithErrorHandlers

Function WithErrorHandlers

pkg/webhandlers/error.go:70–77  ·  view source on GitHub ↗

WithErrorHandlers registers additional error handlers to be used while rendering errors.

(h map[string]http.Handler)

Source from the content-addressed store, hash-verified

68
69// WithErrorHandlers registers additional error handlers to be used while rendering errors.
70func 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
79type errorKeyType struct{}
80

Callers 4

RegisterRoutesMethod · 0.92
RegisterRoutesMethod · 0.92
NewFunction · 0.92
RegisterRoutesMethod · 0.92

Calls 2

ContextMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected