http

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPending = errors.New("http: request pending")

ErrPending is returned when a fetch request is still in flight.

Functions

func ClearCache

func ClearCache(url string)

ClearCache removes any cached response for the given URL.

func FetchJSON

func FetchJSON(url string, v any) error

FetchJSON retrieves JSON data from the given URL and decodes it into v. Results are cached by URL. If a request is already in progress, FetchJSON returns ErrPending.

func FetchText

func FetchText(url string) (string, error)

FetchText retrieves text data from url. Results are cached by URL. If a request is already in progress, FetchText returns ErrPending.

func RegisterHTTPHook

func RegisterHTTPHook(fn func(start bool, url string, status int, duration time.Duration))

RegisterHTTPHook registers fn to receive HTTP request events.

func SetNativeClient

func SetNativeClient(client *stdhttp.Client)

SetNativeClient replaces the native HTTP client. Custom clients may reach private networks and must only receive trusted URLs. Passing nil restores the default client, which rejects private network addresses.

Types

This section is empty.

Jump to

Keyboard shortcuts

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