Documentation
¶
Overview ¶
Package utils provides helper routines for HTTP requests, string transformations, and request fingerprinting.
Index ¶
- func AcquireExponentialBackoff() *backoff.ExponentialBackOff
- func BuildHTTPRequestWithHeaders(method string, requestURL string, body io.Reader, headers map[string]string) (*http.Request, error)
- func Fingerprint(secret string) string
- func GetString(container map[string]any, field string) string
- func HasAnyPrefix(value string, prefixes ...string) bool
- func IsBlank(value string) bool
- func PerformHTTPRequest(executeRequest func(*http.Request) (*http.Response, error), ...) (int, []byte, http.Header, int64, error)
- func ReleaseExponentialBackoff(exponentialBackoff *backoff.ExponentialBackOff)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcquireExponentialBackoff ¶
func AcquireExponentialBackoff() *backoff.ExponentialBackOff
AcquireExponentialBackoff retrieves a reusable exponential backoff instance.
func BuildHTTPRequestWithHeaders ¶
func BuildHTTPRequestWithHeaders(method string, requestURL string, body io.Reader, headers map[string]string) (*http.Request, error)
BuildHTTPRequestWithHeaders constructs an HTTP request and applies headers.
func Fingerprint ¶
Fingerprint returns a short hash you can safely log for diagnostics.
func GetString ¶
GetString returns a string value from the provided container for the specified field.
func HasAnyPrefix ¶
HasAnyPrefix reports whether value starts with any of the given prefixes (case-insensitive).
func PerformHTTPRequest ¶
func PerformHTTPRequest(executeRequest func(*http.Request) (*http.Response, error), httpRequest *http.Request, structuredLogger *zap.SugaredLogger, logEventOnTransportError string) (int, []byte, http.Header, int64, error)
PerformHTTPRequest issues the HTTP request using executeRequest and returns the status code, body, response headers, and latency. It automatically retries transport failures using exponential backoff.
func ReleaseExponentialBackoff ¶
func ReleaseExponentialBackoff(exponentialBackoff *backoff.ExponentialBackOff)
ReleaseExponentialBackoff resets the backoff and returns it to the pool.
Types ¶
This section is empty.