Documentation
¶
Overview ¶
Package httputil provides a thin HTTP+JSON helper for providers.
Index ¶
- Constants
- func GetHTML(url string, headers map[string]string, timeout time.Duration) (string, error)
- func GetJSON(url string, headers map[string]string, timeout time.Duration, dst any) error
- func PostJSON(url string, headers map[string]string, payload any, timeout time.Duration, ...) error
- func Truncate(s string, n int) string
- type Error
Constants ¶
View Source
const DefaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
DefaultUserAgent is sent on every request unless the caller explicitly sets a User-Agent header. Go's default "Go-http-client/1.1" gets blocked by Cloudflare, so we use a real browser UA.
Variables ¶
This section is empty.
Functions ¶
func GetHTML ¶ added in v0.3.0
GetHTML performs a GET request and returns the response body as a string.
Types ¶
Click to show internal directories.
Click to hide internal directories.