client

package
v0.114.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 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.Version + " (+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 ExtractMainContent added in v0.111.0

func ExtractMainContent(ctx context.Context, page string) (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 try to find an image to represent the feed. Useful to call if the feed does not define an image itself.

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