fetch

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MimeTypeJSON = "application/json"
	MimeTypeJpeg = "image/jpeg"
	MimeTypePng  = "image/png"
	MimeTypeZip  = "application/zip"
)

Variables

View Source
var ErrNotFound = &ExternalAPIError{StatusCode: 404, Message: "Not found"}

Functions

This section is empty.

Types

type ContentTypeValidator added in v0.3.1

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

func (ContentTypeValidator) Apply added in v0.3.1

func (v ContentTypeValidator) Apply(resp *http.Response) error

type ExternalAPIError added in v0.3.2

type ExternalAPIError struct {
	Message    string
	StatusCode int
}

func (ExternalAPIError) Error added in v0.3.2

func (e ExternalAPIError) Error() string

func (ExternalAPIError) Is added in v0.3.2

func (e ExternalAPIError) Is(target error) bool

type Fetcher

type Fetcher interface {
	Fetch(url string, handleResponse func(resp *Response) error) error
}

func NewFetcher

func NewFetcher(client *http.Client, validator ...Validator) Fetcher

type MimeType added in v0.3.1

type MimeType struct {
	Value string
}

func NewMimeType added in v0.3.1

func NewMimeType(mimeType string) MimeType

func (MimeType) BuildFilename added in v0.3.1

func (m MimeType) BuildFilename(prefix string) (string, error)

func (MimeType) IsZip added in v0.3.1

func (m MimeType) IsZip() bool

func (MimeType) Raw added in v0.3.1

func (m MimeType) Raw() string

type Response

type Response struct {
	Body        io.Reader
	ContentType string
}

func (*Response) MimeType added in v0.3.1

func (r *Response) MimeType() MimeType

type Validator added in v0.3.1

type Validator interface {
	Apply(resp *http.Response) error
}

func NewContentTypeValidator added in v0.3.1

func NewContentTypeValidator(allowedTypes []string) Validator

Jump to

Keyboard shortcuts

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