| //answerWechatPost distribute PostRequest according to xml body info | //answerWechatPost distribute PostRequest according to xml body info | ||||
| func answerWechatPost(w http.ResponseWriter, r *http.Request) { | func answerWechatPost(w http.ResponseWriter, r *http.Request) { | ||||
| in, valid := readWechatInput(r) | in, valid := readWechatInput(r) | ||||
| in.instantResponse = make(chan string) | |||||
| reply := "" //nothing | reply := "" //nothing | ||||
| w.Header().Set("Content-Type", "text/xml; charset=utf-8") | w.Header().Set("Content-Type", "text/xml; charset=utf-8") | ||||
| //read instant response | //read instant response | ||||
| reply = <-in.instantResponse | reply = <-in.instantResponse | ||||
| close(in.instantResponse) | |||||
| in.destroy() | |||||
| //uncomment the followin two lines to enable echo test | //uncomment the followin two lines to enable echo test | ||||
| // state, _ := echoCommand(in.header.FromUserName, in) | // state, _ := echoCommand(in.header.FromUserName, in) | ||||
| // reply = state.response | // reply = state.response | ||||
| } | } | ||||
| valid = true | valid = true | ||||
| fmt.Printf("decrypt as: %s\n", d) | fmt.Printf("decrypt as: %s\n", d) | ||||
| result.init() | |||||
| result.header = ReadCommonHeader(d) | result.header = ReadCommonHeader(d) | ||||
| switch result.header.MsgType { | switch result.header.MsgType { | ||||
| case "text": | case "text": |