metadata: add iterator method

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-01-21 18:35:31 +03:00
parent dcca28944e
commit 8a2c4c511e
3 changed files with 95 additions and 43 deletions

View File

@@ -2,10 +2,26 @@ package metadata
import (
"context"
"fmt"
"reflect"
"testing"
)
func TestIterator(t *testing.T) {
md := Metadata{
"1Last": "last",
"2First": "first",
"3Second": "second",
}
iter := md.Iterator()
var k, v string
for iter.Next(&k, &v) {
fmt.Printf("k: %s, v: %s\n", k, v)
}
}
func TestMedataCanonicalKey(t *testing.T) {
ctx := Set(context.TODO(), "x-request-id", "12345")
v, ok := Get(ctx, "x-request-id")