Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
965535a403 | ||
|
|
913a8d1d9c | ||
|
|
8cec06641b | ||
|
|
2ec64dc92b | ||
|
|
3ceb440acc | ||
|
|
d6c3570ae7 | ||
|
|
6ee3c99241 |
@@ -50,6 +50,7 @@ func Post(uri string, authName string, authValue string, data any) (*http.Respon
|
|||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
|
|
||||||
|
request.Header.Set("Accept", "application/json")
|
||||||
request.Header.Set("Content-Type", "application/json")
|
request.Header.Set("Content-Type", "application/json")
|
||||||
request.Header.Set("Authorization", fmt.Sprintf("%s %s", authName, authValue))
|
request.Header.Set("Authorization", fmt.Sprintf("%s %s", authName, authValue))
|
||||||
|
|
||||||
@@ -60,3 +61,29 @@ func Post(uri string, authName string, authValue string, data any) (*http.Respon
|
|||||||
|
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Put(uri string, authName string, authValue string, data any) (*http.Response, error) {
|
||||||
|
jsonBytes, err := json.Marshal(data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
body := bytes.NewBuffer(jsonBytes)
|
||||||
|
request, err := http.NewRequest("PUT", uri, body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
client := &http.Client{}
|
||||||
|
|
||||||
|
request.Header.Set("Content-Type", "application/json")
|
||||||
|
request.Header.Set("Accept", "application/json")
|
||||||
|
request.Header.Set("Authorization", fmt.Sprintf("%s %s", authName, authValue))
|
||||||
|
|
||||||
|
response, err := client.Do(request)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return response, nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user