fetch

package
v0.0.0-...-0ad448c Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package fetch provides an API for fetching information about urls.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMention = errors.New("No mention")

ErrNoMention is used when not mention was found

Functions

func FeedHeader

func FeedHeader(fetcher Fetcher, fetchURL, contentType string, body io.Reader) (microsub.Feed, error)

FeedHeader returns a new microsub.Feed with the information parsed from body.

func FeedItems

func FeedItems(fetcher Fetcher, fetchURL, contentType string, body io.Reader) ([]microsub.Item, error)

FeedItems returns the items from the url, parsed from body.

Types

type Fetcher

type Fetcher interface {
	Fetch(url string) (*http.Response, error)
	FetchWithContext(ctx context.Context, url string) (*http.Response, error)
}

Fetcher fetches urls

type FetcherFunc

type FetcherFunc func(ctx context.Context, url string) (*http.Response, error)

FetcherFunc is a function that fetches an url

func (FetcherFunc) Fetch

func (ff FetcherFunc) Fetch(url string) (*http.Response, error)

Fetch fetches an url and returns a response or error

func (FetcherFunc) FetchWithContext

func (ff FetcherFunc) FetchWithContext(ctx context.Context, url string) (*http.Response, error)

FetchWithContext fetches an url and returns a response or error

Jump to

Keyboard shortcuts

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