Documentation
¶
Overview ¶
Package data provides common shared data structures for imageproxy.
Package proxy provides the image proxy.
Package transform handles image transformation such as resizing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NopCache = new(nopCache)
NopCache provides a no-op cache implementation that doesn't actually cache anything.
Functions ¶
Types ¶
type Cache ¶
type Cache interface {
// Get retrieves the cached data for the provided key.
Get(key string) (data []byte, ok bool)
// Set caches the provided data.
Set(key string, data []byte)
// Delete deletes the cached data at the specified key.
Delete(key string)
}
The Cache interface defines a cache for storing arbitrary data. The interface is designed to align with httpcache.Cache.
type Options ¶ added in v0.2.0
type Options struct {
Width float64 // requested width, in pixels
Height float64 // requested height, in pixels
// If true, resize the image to fit in the specified dimensions. Image
// will not be cropped, and aspect ratio will be maintained.
Fit bool
// Rotate image the specified degrees counter-clockwise. Valid values are 90, 180, 270.
Rotate int
FlipVertical bool
FlipHorizontal bool
}
Options specifies transformations that can be performed on a requested image.
func ParseOptions ¶ added in v0.2.0
type Proxy ¶
type Proxy struct {
Client *http.Client // client used to fetch remote URLs
Cache Cache
// Whitelist specifies a list of remote hosts that images can be proxied from. An empty list means all hosts are allowed.
Whitelist []string
MaxWidth int
MaxHeight int
}
Proxy serves image requests.
type Request ¶ added in v0.2.0
type TransformingTransport ¶ added in v0.2.0
type TransformingTransport struct {
// Transport is used to satisfy non-transform requests (those that do not include a URL fragment)
Transport http.RoundTripper
// Client is used to fetch images to be resized.
Client *http.Client
}
TransformingTransport is an implementation of http.RoundTripper that optionally transforms images using the options specified in the request URL fragment.
Click to show internal directories.
Click to hide internal directories.