httpclient

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package httpclient adds project conventions over Azugo's ctx.HTTPClient(): correlation propagation on outbound calls and sane transport defaults.

It owns transport defaults and correlation; go-authbyte owns auth — it attaches the DPoP-bound service token + proof. The two compose: build the outbound client here, then layer go-authbyte's request options on top.

The W3C `traceparent` header is injected automatically by azugo.io/opentelemetry's HTTP-client instrumentation, so this package only adds the project correlation_id header.

Index

Constants

View Source
const (
	// DefaultTimeout is the recommended overall timeout for an outbound call.
	DefaultTimeout = 10 * time.Second
	// DefaultMaxRetries is the recommended bound on retries (with backoff).
	DefaultMaxRetries = 2
)

Default transport conventions. Per-request deadlines still come from the inbound request context (ctx.HTTPClient() inherits it); these document the fleet defaults a service configures on the Azugo http_client section.

Variables

This section is empty.

Functions

func CorrelationOptions

func CorrelationOptions(ctx *azugo.Context) []http.RequestOption

CorrelationOptions returns the Azugo HTTP request options that propagate the request's correlation_id to the upstream service — one option when a correlation id is bound, an empty slice otherwise. Spread it into the request call (variadic expansion of an empty slice is a no-op), which avoids ever passing a typed-nil option into the request pipeline.

func Outbound

func Outbound(ctx *azugo.Context, baseURL string) http.Client

Outbound returns the context-bound HTTP client targeting baseURL. The client is already OpenTelemetry-instrumented (via azugo.io/opentelemetry) and inherits the inbound request's deadline and tracing. Spread CorrelationOptions(ctx) — and, for authenticated calls, go-authbyte's token option — into each request:

c := httpclient.Outbound(ctx, "https://document-svc")
err := c.GetJSON("/v1/documents/"+id, &doc, httpclient.CorrelationOptions(ctx)...)

Types

This section is empty.

Jump to

Keyboard shortcuts

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