0
我有一个处理程序向elasticsearch发出请求。 我的猫得到该请求的JSON响应:转:如何将响应主体转换为请求主体?
resp, err := http.Get(getUrl)
defer resp.Body.Close()
bodyString := ""
if resp.StatusCode == 200{
bodyBytes, err := ioutil.ReadAll(resp.Body)
checkForError(err)
bodyString = string(bodyBytes)
fmt.Fprintf(w, bodyString)
}
如何把这一bodyString
到的东西我可以传递给这类的http.Post:
http.Post("https://httpbin.org/post", "application/json; charset=utf-8", jsonData)