client

package
v0.143.1 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// UserAgent is the string which the `User-Agent` request header will be set to for underlying requests to fetch
	// feeds and content.
	UserAgent = config.AppName + "/" + config.GetVersion() + " (+https://foragd.app/policies/bot)"
	// DefaultHTTPRequestTimeout is the maximum time allowed for a background HTTP request to execute.
	DefaultHTTPRequestTimeout = 45 * time.Second
	// DefaultRequestRetries is the default number of retries for API requests.
	DefaultRequestRetries = 3
)
View Source
var Load = sync.OnceValue(func() *resty.Client {
	client = resty.New().
		SetHeader("User-Agent", UserAgent).
		SetHeader("Accept", "*/*").
		SetHeader("Accept-Encoding", "gzip, deflate")
	return client
})

Functions

func ExtractFavicon added in v0.140.0

func ExtractFavicon(ctx context.Context, page string) (string, error)

ExtractFavicon will attempt to extract the favicon link from a page.

func ExtractMainContent added in v0.111.0

func ExtractMainContent(ctx context.Context, page string, data []byte) (string, error)

ExtractMainContent extracts the main content from the page at the given URL, using the readability package.

func ExtractMainImage added in v0.113.1

func ExtractMainImage(ctx context.Context, page string) (string, error)

ExtractMainImage will attempt to extract a URL to what is likely the "main" image of a page (i.e., typically used on article/post pages).

Types

type HeadReader

type HeadReader struct {
	// contains filtered or unexported fields
}

HeadReader wraps a reader and stops after the </head> tag or a byte limit. This avoids downloading the entire page body.

func NewHeadReader

func NewHeadReader(r io.Reader, maxBytes int) *HeadReader

func (*HeadReader) Read

func (h *HeadReader) Read(page []byte) (int, error)

Jump to

Keyboard shortcuts

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