Documentation
¶
Overview ¶
Package probehttp contains shared helpers for the eyrie credential-probe and catalog-probe call sites. It centralises the HTTP-client configuration and the HTTP-status-to-error mapping that probe code reaches for on every request. Keeping it in one place means timeout policy and error wording stay aligned across credential probes and live catalog probes.
Index ¶
Constants ¶
const DefaultRequestTimeout = 15 * time.Second
DefaultRequestTimeout caps the time a single probe HTTP request can take. The probe context already carries a deadline, but the http.Client.Timeout is a second line of defence: it bounds the time spent in TLS, redirects, and the like even if the caller's context deadline is missing.
Variables ¶
var DefaultClient = &http.Client{Timeout: DefaultRequestTimeout}
DefaultClient is the shared *http.Client used by probe code in the eyrie repo. Callers should reuse it instead of http.DefaultClient so the per-request timeout policy stays consistent.
Functions ¶
func DoGet ¶
DoGet issues a GET against url with the given headers, returns the status code and body. The body is bounded to 1 MiB so a malicious or buggy provider cannot exhaust memory. The body is read and closed on the caller's behalf; callers only need to inspect (status, body, err).
The request inherits the supplied context and the package-level DefaultClient, so a missing context deadline is still capped by the client Timeout.
func JoinURL ¶
JoinURL trims a trailing slash from base and joins it with the supplied path. It's a tiny helper kept here so the various probe call sites stop re-implementing the trim/concat dance.
func ProbeError ¶
ProbeError builds a credential-probe error message for a non-2xx response. The wording is part of the public surface that hawk surfaces to users when /config probe fails, so the strings here are stable.
status is the HTTP status code returned by the provider. The function collapses 401/403 into a single "invalid key" message, distinguishes 429 (rate limited) from a hard 5xx (provider unavailable), and falls back to a generic HTTP-status message for everything else.
Types ¶
This section is empty.