http

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func CheckHTTPStatusCode(statusCode int) error

CheckHTTPStatusCode validates that the HTTP status code is in the range of 2xx.

func EnsureHTTPSuccess

func EnsureHTTPSuccess(statusCode int) error

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.

Jump to

Keyboard shortcuts

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