Documentation
¶
Overview ¶
Package backendutil holds the shared plumbing used by every platform backend under backends/. It exists to eliminate the copy-pasted HTTP-client, hook, retry, and base-URL construction that was previously duplicated (often byte-for-byte) across the seven backend packages.
These helpers are intentionally internal: they are an implementation detail of the backends and must not become part of the SDK's public API.
Index ¶
- func ChainTransport(inner, outer http.RoundTripper) http.RoundTripper
- func ConvertHooks(h *provider.Hooks) *transport.Hooks
- func DefaultBaseURL(base, def string) string
- func HTTPTransport(skipTLS bool) http.RoundTripper
- func MapRetryConfig(rc *provider.RetryConfig) *transport.RetryConfig
- func NormalizeBaseURL(base string) string
- func ToTransportLogger(l provider.Logger) transport.Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChainTransport ¶
func ChainTransport(inner, outer http.RoundTripper) http.RoundTripper
ChainTransport chains two round trippers. The outer tripper is invoked first; if it returns a non-nil response or a non-nil error that result is returned, otherwise the inner transport (the underlying connection) handles the request.
func ConvertHooks ¶
ConvertHooks adapts provider.Hooks into transport.Hooks. The request-hook signatures differ across the two packages (provider.RequestHook returns a context; transport.RequestHook returns an error), so each request hook is wrapped to discard the returned context. Identical across all backends.
func DefaultBaseURL ¶
DefaultBaseURL returns base if non-empty, otherwise def.
func HTTPTransport ¶
func HTTPTransport(skipTLS bool) http.RoundTripper
HTTPTransport returns an http.RoundTripper honouring the skipTLS flag: the default transport when verification is enabled, or a transport that disables certificate verification when the caller has explicitly opted into SkipTLS.
func MapRetryConfig ¶
func MapRetryConfig(rc *provider.RetryConfig) *transport.RetryConfig
MapRetryConfig converts a provider.RetryConfig (which counts retries, i.e. attempts beyond the first) into a transport.RetryConfig (which counts total attempts), hence the +1. Returns nil for a nil input so callers can assign the result directly.
func NormalizeBaseURL ¶
NormalizeBaseURL returns base with a single trailing slash removed and a trailing "/api/v1" suffix removed. Used by Gitea/Forgejo-style backends whose SDKs add the version prefix themselves.
Types ¶
This section is empty.