diff --git a/server.go b/server.go index 4c39541..4984845 100644 --- a/server.go +++ b/server.go @@ -10,7 +10,6 @@ import ( "net/http/httputil" "net/url" "os" - "reflect" "sort" "strings" ) @@ -66,33 +65,16 @@ type InWechatMsg struct { //answerWechatPost distribute PostRequest according to xml body info func answerWechatPost(w http.ResponseWriter, r *http.Request) { in, valid := readWechatInput(r) - //reply := "" //nothing + reply := "" //nothing + w.Header().Set("Content-Type", "text/xml; charset=utf-8") + if !valid { 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) - - //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) {