i have data from interface, and i will add on context. from documentation is context.WithValue(r.Context(), key, val)
i try to add 1 key and value is work, but can't work if more than 1.
result := map[string]interface{}{}
encoded, _ := json.Marshal(data)
json.Unmarshal(encoded, &result)
fmt.Println("data claim \n", result)
var ctx context.Context
for key, val := range result {
fmt.Printf("key %v value %v \n", key, val)
ctx = context.WithValue(r.Context(), key, val)
}
fmt.Println("ctx middleware \n", ctx)
on result i have more than 1 data, but only 1 data is work.
Could you please try this
Seems you are using
r.Context()
all the time but not the updated one.