Skip to content

Commit 844bc71

Browse files
committed
feat(binding): Supplement the body binding of the request using the delete method
Change-Id: I74c2d8950a192f8e4c71ff3b89ace3099611e1d5
1 parent 046b741 commit 844bc71

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

binding/receiver.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,15 @@ func (r *receiver) getBodyCodec(req *http.Request) codec {
9999
}
100100

101101
func (r *receiver) getBody(req *http.Request) ([]byte, string, error) {
102-
if r.hasBody && (req.Method == "POST" || req.Method == "PUT" || req.Method == "PATCH") {
103-
bodyBytes, err := copyBody(req)
104-
if err == nil {
105-
return bodyBytes, goutil.BytesToString(bodyBytes), nil
102+
if r.hasBody {
103+
switch req.Method {
104+
case "POST", "PUT", "PATCH", "DELETE":
105+
bodyBytes, err := copyBody(req)
106+
if err == nil {
107+
return bodyBytes, goutil.BytesToString(bodyBytes), nil
108+
}
109+
return bodyBytes, "", nil
106110
}
107-
return bodyBytes, "", nil
108111
}
109112
return nil, "", nil
110113
}

0 commit comments

Comments
 (0)