fetch

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultUserAgent          = "Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0"
	ErrUnsupportedContentType = UnsupportedContentTypeError{
		HttpError{
			StatusCode: http.StatusUnsupportedMediaType,
			Status:     http.StatusText(http.StatusUnsupportedMediaType),
			Message:    "Unsupported content type",
		},
	}
)

Functions

This section is empty.

Types

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