| "net/http/httputil" | "net/http/httputil" | ||||
| "net/url" | "net/url" | ||||
| "os" | "os" | ||||
| "reflect" | |||||
| "sort" | "sort" | ||||
| "strings" | "strings" | ||||
| ) | ) | ||||
| //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) | ||||
| //reply := "" //nothing | |||||
| reply := "" //nothing | |||||
| w.Header().Set("Content-Type", "text/xml; charset=utf-8") | |||||
| if !valid { | if !valid { | ||||
| log.Println("Error: Invalid Input ") | log.Println("Error: Invalid Input ") | ||||
| } else { | |||||
| //put into user session based pipeline | |||||
| AllInMessage <- in | |||||
| } | } | ||||
| AllInMessage <- in | |||||
| openID := in.header.FromUserName | |||||
| if openID == "" { | |||||
| log.Println("nothing") | |||||
| } | |||||
| //dummy reply | |||||
| reply, _ := BuildTextMsg(openID, "澳") | |||||
| w.Header().Set("Content-Type", "text/xml; charset=utf-8") | |||||
| fmt.Fprint(w, reply) | fmt.Fprint(w, reply) | ||||
| //time.Sleep(5 * time.Second) | |||||
| v := reflect.ValueOf(answerWechatPost) | |||||
| log.Printf("Current Pointer: %d", v.Pointer()) | |||||
| //debug.PrintStack() | |||||
| //load session into memory | |||||
| // session := startSession(openID, in, w, r) //who , input what? | |||||
| // session.ProcessInput() | |||||
| // //put session back to disk | |||||
| // session.Save() | |||||
| } | } | ||||
| // func (session) ProcessInput(w, r) { | // func (session) ProcessInput(w, r) { |