1
0
mirror of synced 2024-11-22 04:56:06 +03:00
mg-transport-api-client-go/v1/helpers.go
Ruslan Efanov 5e3e7cd03d fix review
2022-10-26 18:21:00 +03:00

22 lines
301 B
Go

package v1
import (
"io"
"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 := io.ReadAll(limitReader)
if err != nil {
return body, err
}
return body, nil
}