Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tiantianlikeu committed May 9, 2023
1 parent 091272b commit ab5ef43
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions gin_wechat_server.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wechatgogin

import (
"crypto"
"encoding/json"
"encoding/xml"
"errors"
Expand Down Expand Up @@ -134,13 +135,11 @@ func getEncryptBody(ginWxMsg *GinWxMsg) (*message.EncryptedXMLMsg, error) {
contentType := c.Request.Header.Get("Content-Type")
ginWxMsg.IsJSONContent = strings.Contains(contentType, "application/json")
if ginWxMsg.IsJSONContent {
body, _ := io.ReadAll(c.Request.Body)
if err := json.Unmarshal(body, encryptedXMLMsg); err != nil {
if err := json.NewDecoder(c.Request.Body).Decode(encryptedXMLMsg); err != nil {
return nil, fmt.Errorf("从body中解析json失败,err=%v", err)
}
} else {
body, _ := io.ReadAll(c.Request.Body)
if err := xml.Unmarshal(body, encryptedXMLMsg); err != nil {
if err := xml.NewDecoder(c.Request.Body).Decode(encryptedXMLMsg); err != nil {
return nil, fmt.Errorf("从body中解析xml失败,err=%v", err)
}
}
Expand Down

0 comments on commit ab5ef43

Please sign in to comment.