get with custom types

This commit is contained in:
mr 2024-10-21 11:39:52 +02:00
parent 8e82b87fb3
commit e45fefe883

View File

@ -53,8 +53,16 @@ func NewHTTPCaller(urls map[DataType]map[METHOD]string) *HTTPCaller {
} }
// CallGet calls the GET method on the HTTP server // CallGet calls the GET method on the HTTP server
func (caller *HTTPCaller) CallGet(url string, subpath string) ([]byte, error) { func (caller *HTTPCaller) CallGet(url string, subpath string, types ...string) ([]byte, error) {
resp, err := http.Get(url + subpath) req, err := http.NewRequest(http.MethodGet, url+subpath, bytes.NewBuffer([]byte("")))
if err != nil {
return nil, err
}
for _, t := range types {
req.Header.Set("Content-Type", t)
}
client := &http.Client{}
resp, err := client.Do(req)
if err != nil { if err != nil {
return nil, err return nil, err
} }