helpers.go 327 B

1234567891011121314
  1. package websearch
  2. const (
  3. maxResponseSize = 1 << 20 // 1 MB
  4. errorBodyTruncLen = 200
  5. )
  6. // truncateBody returns a truncated string of body for error messages.
  7. func truncateBody(body []byte) string {
  8. if len(body) <= errorBodyTruncLen {
  9. return string(body)
  10. }
  11. return string(body[:errorBodyTruncLen]) + "...(truncated)"
  12. }