summaryrefslogtreecommitdiff
path: root/plugins/http
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-09-10 00:46:20 +0300
committerValery Piashchynski <[email protected]>2021-09-10 00:46:20 +0300
commit23516b54dd9b382ae3daaba03e677e09d3ab9abe (patch)
tree459e2871f32b027d00b073e723b9f2aa18ed8034 /plugins/http
parentf855d878c281285bd8f468af0dba2521e4f211db (diff)
Fix issue with attributes.Init resets existing attributes
Experiment with protoregistry Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/http')
-rw-r--r--plugins/http/attributes/attributes.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/plugins/http/attributes/attributes.go b/plugins/http/attributes/attributes.go
index 81d9f01d..5df80da4 100644
--- a/plugins/http/attributes/attributes.go
+++ b/plugins/http/attributes/attributes.go
@@ -37,9 +37,14 @@ func (v attrs) del(key string) {
delete(v, key)
}
-// Init returns request with new context and attribute bag.
+// Init is idempotent 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 the PsrContextKey payload
+ if val := r.Context().Value(PsrContextKey); val == nil {
+ return r.WithContext(context.WithValue(r.Context(), PsrContextKey, attrs{}))
+ }
+
+ return r
}
// All returns all context attributes.