fixed metadata hooks
This commit is contained in:
@@ -5,13 +5,13 @@ import (
|
|||||||
|
|
||||||
"go.unistack.org/micro/v4/client"
|
"go.unistack.org/micro/v4/client"
|
||||||
"go.unistack.org/micro/v4/metadata"
|
"go.unistack.org/micro/v4/metadata"
|
||||||
"go.unistack.org/micro/v4/options"
|
|
||||||
"go.unistack.org/micro/v4/server"
|
"go.unistack.org/micro/v4/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
type wrapper struct {
|
type wrapper struct {
|
||||||
client.Client
|
|
||||||
keys []string
|
keys []string
|
||||||
|
|
||||||
|
client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClientWrapper(keys ...string) client.Wrapper {
|
func NewClientWrapper(keys ...string) client.Wrapper {
|
||||||
@@ -36,8 +36,8 @@ func NewClientCallWrapper(keys ...string) client.CallWrapper {
|
|||||||
omd = metadata.New(len(imd))
|
omd = metadata.New(len(imd))
|
||||||
}
|
}
|
||||||
for _, k := range keys {
|
for _, k := range keys {
|
||||||
if v, ok := imd.Get(k); ok && v != "" {
|
if v, ok := imd.Get(k); ok {
|
||||||
omd.Set(k, v)
|
omd.Add(k, v...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !ook {
|
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 {
|
if w.keys == nil {
|
||||||
return w.Client.Call(ctx, req, rsp, opts...)
|
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))
|
omd = metadata.New(len(imd))
|
||||||
}
|
}
|
||||||
for _, k := range w.keys {
|
for _, k := range w.keys {
|
||||||
if v, ok := imd.Get(k); ok && v != "" {
|
if v, ok := imd.Get(k); ok {
|
||||||
omd.Set(k, v)
|
omd.Add(k, v...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !ook {
|
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...)
|
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 {
|
if w.keys == nil {
|
||||||
return w.Client.Stream(ctx, req, opts...)
|
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))
|
omd = metadata.New(len(imd))
|
||||||
}
|
}
|
||||||
for _, k := range w.keys {
|
for _, k := range w.keys {
|
||||||
if v, ok := imd.Get(k); ok && v != "" {
|
if v, ok := imd.Get(k); ok {
|
||||||
omd.Set(k, v)
|
omd.Add(k, v...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !ook {
|
if !ook {
|
||||||
@@ -103,8 +103,8 @@ func NewServerHandlerWrapper(keys ...string) server.HandlerWrapper {
|
|||||||
omd = metadata.New(len(imd))
|
omd = metadata.New(len(imd))
|
||||||
}
|
}
|
||||||
for _, k := range keys {
|
for _, k := range keys {
|
||||||
if v, ok := imd.Get(k); ok && v != "" {
|
if v, ok := imd.Get(k); ok {
|
||||||
omd.Set(k, v)
|
omd.Add(k, v...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !ook {
|
if !ook {
|
||||||
|
Reference in New Issue
Block a user