fetch

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout = 30 * time.Second
)
View Source
const (
	DefaultUserAgent = "Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0"
)

Variables

View Source
var (
	ErrUnsupportedContentType = UnsupportedContentTypeError{
		HttpError{
			StatusCode: http.StatusUnsupportedMediaType,
			Status:     http.StatusText(http.StatusUnsupportedMediaType),
			Message:    "Unsupported content type",
		},
	}
)

Functions

This section is empty.

Types

type BatchOptions added in v0.7.0

type BatchOptions struct {
}

type BatchURLFetcher added in v0.7.0

type BatchURLFetcher interface {
	Batch([]string, BatchOptions) <-chan *resource.WebPage
}

type Client added in v0.8.0

type Client interface {
	Get(url string, headers http.Header) (*http.Response, error)
	Identifier() resource.FetchClient
}

func MustClient added in v0.8.0

func MustClient(options ...ClientOption) Client

func NewClient added in v0.8.0

func NewClient(options ...ClientOption) (Client, error)

type ClientOption added in v0.8.0

type ClientOption func(*defaultClient) error

func WithFiles added in v0.8.0

func WithFiles(path string) ClientOption

func WithHTTPClient added in v0.8.0

func WithHTTPClient(client *http.Client) ClientOption

func WithTimeout added in v0.8.0

func WithTimeout(timeout time.Duration) ClientOption

func WithTransport added in v0.8.0

func WithTransport(transport http.RoundTripper) ClientOption

func WithUserAgent added in v0.8.0

func WithUserAgent(ua string) ClientOption

type Factory

type Factory func() (URLFetcher, error)

type FeedFetcher added in v0.6.3

type FeedFetcher interface {
	Open(context.Context) error
	Fetch(*nurl.URL) (*resource.Feed, error)
	Close() error
}

type HttpError added in v0.6.3

type HttpError struct {
	StatusCode int
	Status     string
	Message    string
}

func NewHTTPError

func NewHTTPError(resp *http.Response) HttpError

TODO: Resolve/make consistent the pointer/value semantics of this and other errors here.

func (HttpError) Error added in v0.6.3

func (e HttpError) Error() string

func (HttpError) Is added in v0.6.3

func (e HttpError) Is(target error) bool

We consider the Is test true if the target is an HttpError. For further resolution, check the StatusCode field of the error. TODO: The idea of providing generic and specific HTTPErors is well-intentioned, but the Is checks are a bit baroque (because to make sense these need to work bidrectionally). Consider simplifying.

func (HttpError) String added in v0.6.3

func (e HttpError) String() string

type URLFetcher added in v0.6.3

type URLFetcher interface {
	Open(context.Context) error
	Fetch(*nurl.URL) (*resource.WebPage, error)
	Close() error
}

type UnsupportedContentTypeError

type UnsupportedContentTypeError struct {
	HttpError
}

func NewUnsupportedContentTypeError

func NewUnsupportedContentTypeError(contentType string) *UnsupportedContentTypeError

func (UnsupportedContentTypeError) Is

func (e UnsupportedContentTypeError) Is(target error) bool

Makes errors.Is(err, ErrUnsupportedContentType) return true for any instance of UnsupportedContentTypeError or for an HttpError with a 415 status code.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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