json - Go: How do I turn response body into request body? -


i have handler makes request elasticsearch. cat json response request:

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) } 

how turn bodystring can pass http.post of sort:

http.post("https://httpbin.org/post", "application/json; charset=utf-8", jsondata) 

i not sure trying achive, may help.

bodybytes, err := ioutil.readall(resp.body) reader := bytes.newreader(bodybytes) http.post("https://httpbin.org/post", "application/json; charset=utf-8", reader)  //or can directly //http.post("https://httpbin.org/post", "application/json; charset=utf-8", resp.body) 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -