Skip to content

Instantly share code, notes, and snippets.

@koral--
Created October 16, 2018 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koral--/c34452e62560a3edaef5308ad4b4b4c9 to your computer and use it in GitHub Desktop.
Save koral--/c34452e62560a3edaef5308ad4b4b4c9 to your computer and use it in GitHub Desktop.
Reading plain text HTTP response
func readJokeFromResponse(response *http.Response) (string, error) {
if response.StatusCode != http.StatusOK {
return "", fmt.Errorf("server returned an error: %s", response.Status)
}
content, err := ioutil.ReadAll(response.Body)
return string(content), err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment