1
0
mirror of synced 2024-11-22 04:56:06 +03:00
mg-transport-api-client-go/v1/helpers.go
2023-05-03 10:44:13 +03:00

33 lines
462 B
Go

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