From b0d46aaec3422bddbc221913be93e3e84af41bee Mon Sep 17 00:00:00 2001 From: Darko Luketic Date: Sun, 14 Nov 2021 16:31:30 +0100 Subject: [PATCH] added ErrorsContextKeyName --- options/options.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) + } +}