Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRelayEndpointHTTPError = errors.New("endpoint returned non 2xx HTTP status code")
Endpoint's backend service returned a non 2xx HTTP status code.
Functions ¶
func CheckHTTPStatusCode ¶
CheckHTTPStatusCode validates that the HTTP status code is in the range of 2xx.
func EnsureHTTPSuccess ¶
EnsureHTTPSuccess returns an error if the status code is not a 2xx successful status code. Otherwise returns nil.
Types ¶
type HTTPClientWithDebugMetrics ¶
type HTTPClientWithDebugMetrics struct {
// contains filtered or unexported fields
}
HTTPClientWithDebugMetrics provides HTTP client functionality with embedded tracking of debug metrics. It includes things like: - Built-in request debugging - Metrics collection - Detailed logging - Timeout debugging - Connection issue visibility
func NewDefaultHTTPClientWithDebugMetrics ¶
func NewDefaultHTTPClientWithDebugMetrics() *HTTPClientWithDebugMetrics
NewDefaultHTTPClientWithDebugMetrics creates a new HTTP client with: - Transport settings configured for high-concurrency usage - Built in request debugging capabilities and metrics tracking TODO_TECHDEBT(@adshmh): Make HTTP client settings configurable
func (*HTTPClientWithDebugMetrics) SendHTTPRelay ¶
func (h *HTTPClientWithDebugMetrics) SendHTTPRelay( ctx context.Context, logger polylog.Logger, endpointURL string, method string, relayRequestBz []byte, headers map[string]string, ) ([]byte, int, error)
SendHTTPRelay sends an HTTP POST request with the relay data to the specified URL. Uses the provided context for timeout and cancellation control. Logs detailed metrics and debugging information on failure for debugging.
Returns: response body, HTTP status code, error
type HTTPResponse ¶
type HTTPResponse interface {
GetPayload() []byte
GetHTTPStatusCode() int
// TODO_IMPROVE: return http.Header instead of a map[string]string.
GetHTTPHeaders() map[string]string
}
HTTPResponse allows passing around an HTTP response intended to be received by the user. It is used instead of the standard http.Response to minimze the requirements for producers and clarify the data items that will be used when the writing of the HTTP response takes place.