2022-10-26 10:54:54 +03:00
|
|
|
package v1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
2022-10-28 10:05:11 +03:00
|
|
|
"io/ioutil"
|
2022-10-26 10:54:54 +03:00
|
|
|
"net/http"
|
2022-11-03 17:26:48 +03:00
|
|
|
"time"
|
2022-10-26 10:54:54 +03:00
|
|
|
)
|
|
|
|
|
2022-10-26 14:58:32 +03:00
|
|
|
const MB = 1 << 20
|
2023-09-01 15:08:41 +03:00
|
|
|
const LimitResponse = 25 * MB
|
2022-10-26 14:58:32 +03:00
|
|
|
|
|
|
|
func buildLimitedRawResponse(resp *http.Response) ([]byte, error) {
|
2022-10-26 10:54:54 +03:00
|
|
|
defer resp.Body.Close()
|
|
|
|
|
2023-05-03 10:44:13 +03:00
|
|
|
limitReader := io.LimitReader(resp.Body, LimitResponse)
|
2022-10-28 10:05:11 +03:00
|
|
|
body, err := ioutil.ReadAll(limitReader)
|
2022-10-26 14:58:32 +03:00
|
|
|
|
2022-10-26 10:54:54 +03:00
|
|
|
if err != nil {
|
2022-10-26 14:58:32 +03:00
|
|
|
return body, err
|
2022-10-26 10:54:54 +03:00
|
|
|
}
|
|
|
|
|
2022-10-26 14:58:32 +03:00
|
|
|
return body, nil
|
2022-10-26 10:54:54 +03:00
|
|
|
}
|
2022-11-03 17:26:48 +03:00
|
|
|
|
2023-12-28 14:26:49 +03:00
|
|
|
// BoolPtr returns provided boolean as pointer. Can be used while editing the integration module activity.
|
2022-11-03 17:26:48 +03:00
|
|
|
func BoolPtr(v bool) *bool {
|
|
|
|
return &v
|
|
|
|
}
|
|
|
|
|
2023-12-28 14:26:49 +03:00
|
|
|
// TimePtr returns provided time.Time's pointer.
|
2022-11-03 17:26:48 +03:00
|
|
|
func TimePtr(v time.Time) *time.Time {
|
|
|
|
return &v
|
|
|
|
}
|