Skip to content

Commit

Permalink
debug : content type
Browse files Browse the repository at this point in the history
  • Loading branch information
hxms committed Jan 21, 2024
1 parent e2c49c5 commit 23bf2d9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions api/handler/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func (h *rpcHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}

fmt.Println("Content-Type: ", ct)
fmt.Println(ct, hasCodec(ct, protoCodecs), hasCodec(ct, jsonCodecs))

// micro client
c := h.opts.Client
Expand Down Expand Up @@ -212,6 +213,9 @@ func (h *rpcHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
&request,
client.WithContentType(ct),
)

fmt.Println("default request", ct, req.ContentType())

// make the call
if err := c.Call(cx, req, &response, client.WithSelectOption(so)); err != nil {
writeError(w, r, err)
Expand All @@ -235,8 +239,8 @@ func (rh *rpcHandler) String() string {
}

func hasCodec(ct string, codecs []string) bool {
for _, codec := range codecs {
if ct == codec {
for _, code := range codecs {
if ct == code {
return true
}
}
Expand Down

0 comments on commit 23bf2d9

Please sign in to comment.