backendutil

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 7 Imported by: 0

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

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

func ConvertHooks(h *provider.Hooks) *transport.Hooks

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

func DefaultBaseURL(base, def string) string

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

func NormalizeBaseURL(base string) string

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.

func ToTransportLogger

func ToTransportLogger(l provider.Logger) transport.Logger

ToTransportLogger adapts a provider.Logger to a transport.Logger.

Types

This section is empty.

Jump to

Keyboard shortcuts

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