我有一个向 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)
萧十郎
相关分类