utils

package
v0.2.32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package utils provides helper routines for HTTP requests, string transformations, and request fingerprinting.

Index

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

func Fingerprint(secret string) string

Fingerprint returns a short hash you can safely log for diagnostics.

func GetString

func GetString(container map[string]any, field string) string

GetString returns a string value from the provided container for the specified field.

func HasAnyPrefix

func HasAnyPrefix(value string, prefixes ...string) bool

HasAnyPrefix reports whether value starts with any of the given prefixes (case-insensitive).

func IsBlank

func IsBlank(value string) bool

IsBlank reports whether a string is empty or whitespace-only.

func PerformHTTPRequest

func PerformHTTPRequest(executeRequest func(*http.Request) (*http.Response, error), httpRequest *http.Request, structuredLogger *zap.SugaredLogger, logEventOnTransportError string) (int, []byte, int64, error)

PerformHTTPRequest issues the HTTP request using executeRequest and returns the status code, body, 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL