Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
7
Help us understand the problem. What is going on with this article?
@shinofara

http.client.Doでretryをするとき

More than 5 years have passed since last update.

これでいけるかな?と思ってたけど

client := &http.Client{}
req, _ := http.NewRequest("POST", "http://localhost", bytes.NewBuffer([]byte(`test`))) 

resp, err := client.Do(req)
if err != nil {
  resp, err = client.Do(req)
}

けど

client := &http.Client{}
req, _ := http.NewRequest("POST", "http://localhost", bytes.NewBuffer([]byte(`test`))) 

resp, err := client.Do(req)
if err != nil {
  req, _ := http.NewRequest("POST", "http://localhost", bytes.NewBuffer([]byte(`test`))) 
  req.Header.Set("Content-Type", "application/json") 
  resp, err = client.Do(req)
}

requestを作りなおさないと行けないみたい
もし再利用する方法があれば教えてください

7
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
shinofara
work: Emacs/VisualStudioCode Golang/PHP/Pyhton/Shell AWS/Docker/VirtualBox/Mac Vagrant/Terraform/Packer/Ansible OSS/LT like: Photo/Diving/Snowboard history: Y! -> schoo -> Y! -> MedPeer
moneyforward
「お金を前へ。人生をもっと前へ。」をMissionとして、個人向け、法人向け様々なFintechサービスを開発、提供しています。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
7
Help us understand the problem. What is going on with this article?