add request to personal information

This commit is contained in:
kandrusyak
2023-08-03 00:53:18 +03:00
parent 15f51516af
commit 0364ad2d7d
3 changed files with 48 additions and 10 deletions

View File

@@ -7,11 +7,11 @@ import (
"net/http"
)
func PostRequest(url string, model any, header http.Header) ([]byte, error) {
func PostRequest(url string, model any, header http.Header) ([]byte, error, *http.Response) {
uJson, err := json.Marshal(model)
if err != nil {
return nil, err
return nil, err, nil
}
client := http.Client{}
@@ -22,16 +22,16 @@ func PostRequest(url string, model any, header http.Header) ([]byte, error) {
resp, err := client.Do(req)
if err != nil {
return nil, err
return nil, err, nil
}
data, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
return nil, err, nil
}
return data, nil
return data, nil, resp
}
func GetRequest(url string, header http.Header, args ...string) ([]byte, error, *http.Response) {