add store service
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user