mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
25 lines
No EOL
590 B
Go
25 lines
No EOL
590 B
Go
package api
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
)
|
|
|
|
|
|
func MakeRequest(url string, httpMethod string, body []byte) (*http.Response, []byte, error) {
|
|
// url := getSmdEndpointUrl(endpoint)
|
|
req, _ := http.NewRequest(httpMethod, url, bytes.NewBuffer(body))
|
|
req.Header.Add("User-Agent", "magellan")
|
|
res, err := http.DefaultClient.Do(req)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("could not make request: %v", err)
|
|
}
|
|
b, err := io.ReadAll(res.Body)
|
|
res.Body.Close()
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("could not read response body: %v", err)
|
|
}
|
|
return res, b, err
|
|
} |