Created
June 19, 2015 14:10
-
-
Save daemonfire300/477efceabc6bec947718 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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