package main import ( "io/ioutil" "log" "net/http" "net/url" "testing" ) func TestCallback(t *testing.T) { // eg := gin.New() // eg.POST("/callback", func(c *gin.Context) { // if tid, ok := c.GetPostForm("taskid"); ok { // log.Println(tid) // } // }) http.HandleFunc("/callback", func(rw http.ResponseWriter, r *http.Request) { tid := r.PostFormValue("taskid") log.Println("tid: ", tid) }) go func() { data := url.Values{} data["url"] = []string{"https://playerduo.com/api/playerDuo-service-v2/rip113?lang=en&deviceType=browser"} data["callback"] = []string{"http://localhost:4848/callback"} resp, err := http.DefaultClient.PostForm("http://localhost:7123/task/put", data) if err != nil { panic(err) } bodyRes, err := ioutil.ReadAll(resp.Body) if err != nil { panic(err) } log.Println(string(bodyRes)) // resp, err := requests.NewSession().Post("http://localhost:7123/task/put").SetBodyAuto(data, requests.TypeFormData).Execute() // if err != nil { // log.Println(err) // } else { // log.Println(string(resp.Content())) // } }() // eg.Run(":4848") log.Fatal(http.ListenAndServe(":4848", nil)) }