fix: consistent use of client var

master
phga 3 years ago
parent 15736f91d9
commit db25867e57

@ -50,7 +50,7 @@ Examples:
args := os.Args[l:]
al := len(args)
// Requested url/web resource
resource := args[al - 1]
resource := args[al-1]
// http client used for PUT, PATCH, DELETE
client := &http.Client{}
@ -96,10 +96,12 @@ Note: Use "" around everything but numbers, also wrap json in ''
os.Exit(1)
}
data := args[0]
res, err := http.Post(resource, "application/json; charset=UTF-8", bytes.NewBufferString(data))
req, err := http.NewRequest(http.MethodPost, resource, bytes.NewBufferString(data))
if err != nil {
log.Fatal(err)
}
req.Header.Set("Content-Type", "application/json; charset=UTF-8")
res, err := client.Do(req)
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
@ -120,7 +122,7 @@ Note: Use "" around everything but numbers, also wrap json in ''
os.Exit(1)
}
data := args[0]
req, err := http.NewRequest(http.MethodPut, resource ,bytes.NewBufferString(data))
req, err := http.NewRequest(http.MethodPut, resource, bytes.NewBufferString(data))
if err != nil {
log.Fatal(err)
}
@ -146,7 +148,7 @@ Note: Use "" around everything but numbers, also wrap json in ''
os.Exit(1)
}
data := args[0]
req, err := http.NewRequest(http.MethodPatch, resource ,bytes.NewBufferString(data))
req, err := http.NewRequest(http.MethodPatch, resource, bytes.NewBufferString(data))
if err != nil {
log.Fatal(err)
}

Loading…
Cancel
Save