fix: consistent use of client var
This commit is contained in:
parent
15736f91d9
commit
db25867e57
10
main.go
10
main.go
@ -50,7 +50,7 @@ Examples:
|
|||||||
args := os.Args[l:]
|
args := os.Args[l:]
|
||||||
al := len(args)
|
al := len(args)
|
||||||
// Requested url/web resource
|
// Requested url/web resource
|
||||||
resource := args[al - 1]
|
resource := args[al-1]
|
||||||
// http client used for PUT, PATCH, DELETE
|
// http client used for PUT, PATCH, DELETE
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
|
|
||||||
@ -96,10 +96,12 @@ Note: Use "" around everything but numbers, also wrap json in ''
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
data := args[0]
|
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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
req.Header.Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
|
res, err := client.Do(req)
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
body, err := ioutil.ReadAll(res.Body)
|
body, err := ioutil.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -120,7 +122,7 @@ Note: Use "" around everything but numbers, also wrap json in ''
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
data := args[0]
|
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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -146,7 +148,7 @@ Note: Use "" around everything but numbers, also wrap json in ''
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
data := args[0]
|
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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user