From a2af88883d488a5a282d7acee67871b854a4ab07 Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Sat, 3 Jun 2017 00:45:01 +1000 Subject: [PATCH] using InWechagMsg member function. --- server.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.go b/server.go index 1ffdc4c..e2c7083 100644 --- a/server.go +++ b/server.go @@ -58,7 +58,6 @@ func answerInitialAuth(w http.ResponseWriter, r *http.Request) { //answerWechatPost distribute PostRequest according to xml body info func answerWechatPost(w http.ResponseWriter, r *http.Request) { in, valid := readWechatInput(r) - in.instantResponse = make(chan string) reply := "" //nothing w.Header().Set("Content-Type", "text/xml; charset=utf-8") @@ -71,7 +70,7 @@ func answerWechatPost(w http.ResponseWriter, r *http.Request) { //read instant response reply = <-in.instantResponse - close(in.instantResponse) + in.destroy() //uncomment the followin two lines to enable echo test // state, _ := echoCommand(in.header.FromUserName, in) // reply = state.response @@ -93,6 +92,7 @@ func readWechatInput(r *http.Request) (result InWechatMsg, valid bool) { } valid = true fmt.Printf("decrypt as: %s\n", d) + result.init() result.header = ReadCommonHeader(d) switch result.header.MsgType { case "text":