Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8cec06641b | ||
|
|
2ec64dc92b |
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -38,7 +37,7 @@ func Get(uri string, authName string, authValue string, queries map[string]strin
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func Post(uri string, authName string, authValue string, data io.Reader) (*http.Response, error) {
|
||||
func Post(uri string, authName string, authValue string, data any) (*http.Response, error) {
|
||||
jsonBytes, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -64,7 +63,7 @@ func Post(uri string, authName string, authValue string, data io.Reader) (*http.
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func Put(uri string, authName string, authValue string, data io.Reader) (*http.Response, error) {
|
||||
func Put(uri string, authName string, authValue string, data any) (*http.Response, error) {
|
||||
jsonBytes, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -79,6 +78,7 @@ func Put(uri string, authName string, authValue string, data io.Reader) (*http.R
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user