add store service

This commit is contained in:
kandrusyak
2023-06-30 17:13:46 +03:00
parent 7f4122360f
commit 8f904217f2
5 changed files with 39 additions and 7 deletions

View File

@@ -34,25 +34,27 @@ func PostRequest(url string, model any, header http.Header) ([]byte, error) {
return data, nil
}
func GetRequest(url string, header http.Header, args ...string) ([]byte, error) {
func GetRequest(url string, header http.Header, args ...string) ([]byte, error, *http.Response) {
client := http.Client{}
req, err := http.NewRequest("GET", url, nil)
req.URL.RawQuery = args[0]
if len(args) > 0 {
req.URL.RawQuery = args[0]
}
req.Header = header
req.Header.Set("Content-Type", "application/json")
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 PatchRequest(url string, model any, header http.Header) ([]byte, error) {