Skip to content

Instantly share code, notes, and snippets.

@daemonfire300
Created June 19, 2015 14:10
Show Gist options
  • Save daemonfire300/477efceabc6bec947718 to your computer and use it in GitHub Desktop.
Save daemonfire300/477efceabc6bec947718 to your computer and use it in GitHub Desktop.
func writeProtoTextResponse(w http.ResponseWriter, pb proto.Message) {
data, err := proto.Marshal(pb)
//w.Header().Set("Content-Length", strconv.Itoa(len(data)))
fmt.Println(err)
fmt.Println(data)
fmt.Fprint(w, data)
}
func TestGetProduct(t *testing.T) {
client := &http.Client{}
log.Println("Starting Request")
resp, err := client.Get("http://localhost:8181/apiendpoint")
defer resp.Body.Close()
if err != nil {
log.Println(err)
}
log.Println("Reading Request")
data, err := ioutil.ReadAll(resp.Body)
log.Println("err", err)
log.Println(http.DetectContentType(data))
log.Println("Reading finished")
if err != nil {
t.Log(err)
}
log.Println("HTTP Resp", data)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment