Skip to content

Commit 4c4a024

Browse files
authored
fix for headers with hyphens (#155)
1 parent b93e634 commit 4c4a024

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

http.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"bufio"
66
"bytes"
77
"context"
8+
stderr "errors"
89
"fmt"
910
"io"
1011
"net"
@@ -177,6 +178,11 @@ func newRequest(ctx context.Context, log logger.Logger, addr string, req client.
177178
for km, vm := range parameters {
178179
for k, required := range vm {
179180
v, err = rutil.StructFieldByPath(msg, k)
181+
if stderr.Is(err, rutil.ErrNotFound) {
182+
// Note: check the `json_name` in the `protobuf` tag for headers with hyphens,
183+
// since struct fields cannot contain hyphens.
184+
v, err = rutil.StructFieldByTag(msg, "protobuf", fmt.Sprintf("json=%s", k))
185+
}
180186
if err != nil {
181187
return nil, errors.BadRequest("go.micro.client", "%+v", err)
182188
}

0 commit comments

Comments
 (0)