fixed metadata hooks
Some checks failed
lint / lint (pull_request) Failing after 1m43s
test / test (pull_request) Successful in 2m37s
coverage / build (pull_request) Failing after 5m52s

This commit is contained in:
2025-04-23 20:50:44 +03:00
parent 053fe2a69d
commit dee7bc9c38

View File

@@ -5,13 +5,13 @@ import (
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/options"
"go.unistack.org/micro/v4/server"
)
type wrapper struct {
client.Client
keys []string
client.Client
}
func NewClientWrapper(keys ...string) client.Wrapper {
@@ -36,8 +36,8 @@ func NewClientCallWrapper(keys ...string) client.CallWrapper {
omd = metadata.New(len(imd))
}
for _, k := range keys {
if v, ok := imd.Get(k); ok && v != "" {
omd.Set(k, v)
if v, ok := imd.Get(k); ok {
omd.Add(k, v...)
}
}
if !ook {
@@ -49,7 +49,7 @@ func NewClientCallWrapper(keys ...string) client.CallWrapper {
}
}
func (w *wrapper) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...options.Option) error {
func (w *wrapper) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error {
if w.keys == nil {
return w.Client.Call(ctx, req, rsp, opts...)
}
@@ -59,8 +59,8 @@ func (w *wrapper) Call(ctx context.Context, req client.Request, rsp interface{},
omd = metadata.New(len(imd))
}
for _, k := range w.keys {
if v, ok := imd.Get(k); ok && v != "" {
omd.Set(k, v)
if v, ok := imd.Get(k); ok {
omd.Add(k, v...)
}
}
if !ook {
@@ -70,7 +70,7 @@ func (w *wrapper) Call(ctx context.Context, req client.Request, rsp interface{},
return w.Client.Call(ctx, req, rsp, opts...)
}
func (w *wrapper) Stream(ctx context.Context, req client.Request, opts ...options.Option) (client.Stream, error) {
func (w *wrapper) Stream(ctx context.Context, req client.Request, opts ...client.CallOption) (client.Stream, error) {
if w.keys == nil {
return w.Client.Stream(ctx, req, opts...)
}
@@ -80,8 +80,8 @@ func (w *wrapper) Stream(ctx context.Context, req client.Request, opts ...option
omd = metadata.New(len(imd))
}
for _, k := range w.keys {
if v, ok := imd.Get(k); ok && v != "" {
omd.Set(k, v)
if v, ok := imd.Get(k); ok {
omd.Add(k, v...)
}
}
if !ook {
@@ -103,8 +103,8 @@ func NewServerHandlerWrapper(keys ...string) server.HandlerWrapper {
omd = metadata.New(len(imd))
}
for _, k := range keys {
if v, ok := imd.Get(k); ok && v != "" {
omd.Set(k, v)
if v, ok := imd.Get(k); ok {
omd.Add(k, v...)
}
}
if !ook {