1
0
mirror of synced 2024-11-25 14:36:03 +03:00
mg-transport-api-client-go/v1/helpers.go
2022-10-28 10:05:11 +03:00

23 lines
318 B
Go

package v1
import (
"io"
"io/ioutil"
"net/http"
)
const MB = 1 << 20
func buildLimitedRawResponse(resp *http.Response) ([]byte, error) {
defer resp.Body.Close()
limitReader := io.LimitReader(resp.Body, MB)
body, err := ioutil.ReadAll(limitReader)
if err != nil {
return body, err
}
return body, nil
}