domain

package
v0.0.0-...-50433a0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFetchImage = errors.New("cannot fetch source image")
	ErrHasNoCache = errors.New("cannot fetch image in cache")
)

Functions

This section is empty.

Types

type ContentTypeResizer

type ContentTypeResizer struct {
	Mapping        map[string]Resizer
	DefaultResizer Resizer
}

ContentTypeResizer use one of Mapping resizers depends on content type. If content type has no resizer, DefaultResizer will be used.

func (*ContentTypeResizer) Resize

func (c *ContentTypeResizer) Resize(ct string, inBuf, outBuf *bytes.Buffer, w int, h int) error

Resize choose resizer for handle image

type Domain

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

func New

func New(httpClient *http.Client, resizer Resizer, dbFilepath string) (*Domain, error)

func (*Domain) FetchResize

func (d *Domain) FetchResize(ctx context.Context, buf *bytes.Buffer, url string, w, h int) (string, error)

type JPEG

type JPEG struct{}

JPEG implements Resizer interface for jpeg images

func (*JPEG) Resize

func (c *JPEG) Resize(ct string, inBuf, outBuf *bytes.Buffer, w int, h int) error

Resize is a function, that resize input image

type Proxy

type Proxy struct{}

Proxy is a dummy Resizer - just proxy bytes to result buffer

func (*Proxy) Resize

func (c *Proxy) Resize(ct string, inBuf, outBuf *bytes.Buffer, w int, h int) error

Resize just copy bytes to result buf

type Resizer

type Resizer interface {
	Resize(ct string, inBuf, outBuf *bytes.Buffer, w int, h int) error
}

Resizer is an interface for resize image

Jump to

Keyboard shortcuts

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