1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-03-01 00:35:26 +08:00

feat: improve comment and upgrade golang version 1.16 (#604)

* feat: improve action config and code comment

* feat: improve comment and upgrade golang version 1.16

* feat: improve import
This commit is contained in:
houseme
2022-08-23 10:13:24 +08:00
committed by GitHub
parent df62164811
commit a8f7a24ff6
13 changed files with 84 additions and 64 deletions

View File

@@ -5,7 +5,7 @@ import (
"encoding/xml"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"reflect"
"runtime/debug"
@@ -13,11 +13,11 @@ import (
"strings"
log "github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
"github.com/silenceper/wechat/v2/officialaccount/context"
"github.com/silenceper/wechat/v2/officialaccount/message"
"github.com/silenceper/wechat/v2/util"
"github.com/tidwall/gjson"
)
// Server struct
@@ -106,7 +106,7 @@ func (srv *Server) handleRequest() (reply *message.Reply, err error) {
srv.isSafeMode = true
}
//set request contentType
// set request contentType
contentType := srv.Request.Header.Get("Content-Type")
srv.isJSONContent = strings.Contains(contentType, "application/json")
@@ -162,7 +162,7 @@ func (srv *Server) getMessage() (interface{}, error) {
return nil, fmt.Errorf("消息解密失败, err=%v", err)
}
} else {
rawXMLMsgBytes, err = ioutil.ReadAll(srv.Request.Body)
rawXMLMsgBytes, err = io.ReadAll(srv.Request.Body)
if err != nil {
return nil, fmt.Errorf("从body中解析xml失败, err=%v", err)
}
@@ -193,7 +193,7 @@ func (srv *Server) parseRequestMessage(rawXMLMsgBytes []byte) (msg *message.MixM
err = xml.Unmarshal(rawXMLMsgBytes, msg)
return
}
//parse json
// parse json
err = json.Unmarshal(rawXMLMsgBytes, msg)
if err != nil {
return