package wechat import ( "bytes" "encoding/json" sh "git.chuangxin1.com/myth/sacred/xhttp" ) // getJSON GET response JSON func getJSON(uri string, v interface{}) (msg sh.Message, err error) { opt := sh.DefaultRequestOption() opt.AcceptEncodingGZIP() msg, err = sh.GetJSON(v, uri, opt) //fmt.Println(string(msg.Body), err) return } // postJSON POST json data and response JSON func postJSON(v interface{}, uri string, data interface{}) (msg sh.Message, err error) { bs, _ := json.Marshal(data) opt := sh.DefaultRequestOption() opt.AcceptEncodingGZIP() opt.SetContentTypeJSON() msg, err = sh.Post(uri, bytes.NewReader(bs), opt) if err != nil { return } err = msg.JSON(v) return }