probehttp

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 6 Imported by: 0

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

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

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

func DoGet(ctx context.Context, url string, headers map[string]string) (int, []byte, error)

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

func JoinURL(base, path string) string

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

func ProbeError(status int) error

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.

func UserAgent

func UserAgent() string

UserAgent returns the standard eyrie User-Agent string for probe traffic.

Types

This section is empty.

Jump to

Keyboard shortcuts

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