diff --git a/options/options.go b/options/options.go index af1e79c..a5a4d5b 100644 --- a/options/options.go +++ b/options/options.go @@ -9,6 +9,9 @@ import ( // Using separate type because of the following: https://staticcheck.io/docs/checks#SA1029 type ClaimsContextKeyName string +// ErrosContextKeyName holds the key to pass errors under. +type ErrorsContextKeyName string + // DefaultClaimsContextKeyName is of type ClaimsContextKeyName and defaults to "claims" const DefaultClaimsContextKeyName ClaimsContextKeyName = "claims" @@ -46,6 +49,7 @@ type Options struct { ClaimsContextKeyName ClaimsContextKeyName ErrorHandler ErrorHandler Permissive bool + ErrorsContextKeyName ErrorsContextKeyName } // New takes Option setters and returns an Options pointer. @@ -270,3 +274,11 @@ func WithPermissive() Option { opts.Permissive = true } } + +// WithErrorsContextKeyName sets the ErrorsContextKeyName parameter for an Options pointer. +// ErrorsContextKeyName is the name of the key that will be used to pass errors using the request context. +func WithErrorsContextKeyName(opt string) Option { + return func(opts *Options) { + opts.ErrorsContextKeyName = ErrorsContextKeyName(opt) + } +}