diff options
author | Valery Piashchynski <[email protected]> | 2021-09-10 13:23:06 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-09-10 13:23:06 +0300 |
commit | 1c6fee9490376aefa6214a72b5a83846e9b9337d (patch) | |
tree | 16437a2150818ba328335509169e1b9b27fda60b /plugins/http/attributes/attributes.go | |
parent | 2df4696d85f76c58b014748bf06bf50d84116903 (diff) |
do not overwrite psr http attributes on attributes.Init
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/http/attributes/attributes.go')
-rw-r--r-- | plugins/http/attributes/attributes.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/http/attributes/attributes.go b/plugins/http/attributes/attributes.go index 81d9f01d..243b6c78 100644 --- a/plugins/http/attributes/attributes.go +++ b/plugins/http/attributes/attributes.go @@ -39,7 +39,11 @@ func (v attrs) del(key string) { // Init returns request with new context and attribute bag. func Init(r *http.Request) *http.Request { - return r.WithContext(context.WithValue(r.Context(), PsrContextKey, attrs{})) + // do not overwrite psr attributes + if val := r.Context().Value(PsrContextKey); val == nil { + return r.WithContext(context.WithValue(r.Context(), PsrContextKey, attrs{})) + } + return r } // All returns all context attributes. |