Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultImageDecode(r io.Reader) (image.Image, error)
- func GetImage(url string) ([]byte, string, error)
- func ImageToBytes(i image.Image, hint string, quality int) (*bytes.Buffer, error)
- func IsExpired(info FileInfo) bool
- func NewGCloudLogger(project, name string, opts ...option.ClientOption) (*logging.Client, *logger.Google, error)
- func ReaderToImage(r io.ReadSeeker, hint string) (image.Image, string, error)
- func Resize(fs FileSystem, opts ResizeOptions) error
- func ResizeImage(img image.Image, target uint) (image.Image, error)
- func WriteError(w http.ResponseWriter, err error)
- type FileInfo
- type FileInfoRead
- type FileInfoWrite
- type FileSystem
- type GCloudFileInfo
- type GCloudFileSystem
- func (fs *GCloudFileSystem) Delete(filename string) error
- func (fs *GCloudFileSystem) FromVolume(name string) FileSystem
- func (fs *GCloudFileSystem) GetBucket(bucket string) *storage.BucketHandle
- func (fs *GCloudFileSystem) Info(filename string) (FileInfo, error)
- func (fs *GCloudFileSystem) ObjectURL(filename string) string
- func (fs *GCloudFileSystem) ReadCloser(filename string) (io.ReadCloser, error)
- func (fs *GCloudFileSystem) Write(filename string, r io.Reader, info FileInfoWrite) error
- type GCloudPubSub
- type HTTPError
- type Messager
- type ParamError
- type Publisher
- type ResizeOptions
- type ResizeOptionsProcessed
- type RootError
- type Subscriber
- type Subscription
- type SystemError
- type WriteInfo
Constants ¶
const MaxImageDimension = 4096
const ResizeTopic = "asset-delivery-resize"
PubSub topic for sending and receiving resize request
Variables ¶
var ( ErrFileNotHandled = errors.New("file type not handled") ErrInvalidBounds = errors.New("invalid image bounds") )
var ErrNoFile = errors.New("no file")
Functions ¶
func ImageToBytes ¶
func IsExpired ¶
IsExpired reports whether info is past its Cache-Control max-age. An object with no max-age never expires (returns false).
func NewGCloudLogger ¶
func ReaderToImage ¶
ReaderToImage decodes r as an image, using hint's extension to pick the decoder when it names a supported format and falling back to image.Decode otherwise. The returned format is the auto-detected format name ("jpeg", "png", "webp", ...) when the fallback path is taken, or the format implied by the hint when the typed decoder succeeds. Callers can use it to choose an output encoding when the hint URL has no extension.
func Resize ¶
func Resize(fs FileSystem, opts ResizeOptions) error
func WriteError ¶
func WriteError(w http.ResponseWriter, err error)
Types ¶
type FileInfo ¶
type FileInfo interface {
FileInfoWrite
FileInfoRead
}
type FileInfoRead ¶
type FileInfoWrite ¶
type FileInfoWrite interface {
CacheControl() string
}
type FileSystem ¶
type GCloudFileInfo ¶
type GCloudFileInfo struct {
// contains filtered or unexported fields
}
func (*GCloudFileInfo) CacheControl ¶
func (i *GCloudFileInfo) CacheControl() string
func (*GCloudFileInfo) Created ¶
func (i *GCloudFileInfo) Created() time.Time
type GCloudFileSystem ¶
type GCloudFileSystem struct {
Client *storage.Client
Host string
Bucket string
// contains filtered or unexported fields
}
func NewGCloudFileSystem ¶
func NewGCloudFileSystem(opts ...option.ClientOption) (*GCloudFileSystem, error)
func (*GCloudFileSystem) Delete ¶
func (fs *GCloudFileSystem) Delete(filename string) error
func (*GCloudFileSystem) FromVolume ¶
func (fs *GCloudFileSystem) FromVolume(name string) FileSystem
func (*GCloudFileSystem) GetBucket ¶
func (fs *GCloudFileSystem) GetBucket(bucket string) *storage.BucketHandle
func (*GCloudFileSystem) ObjectURL ¶
func (fs *GCloudFileSystem) ObjectURL(filename string) string
func (*GCloudFileSystem) ReadCloser ¶
func (fs *GCloudFileSystem) ReadCloser(filename string) (io.ReadCloser, error)
func (*GCloudFileSystem) Write ¶
func (fs *GCloudFileSystem) Write(filename string, r io.Reader, info FileInfoWrite) error
type GCloudPubSub ¶
func NewGCloudPubSub ¶
func NewGCloudPubSub(projectId string, opts ...option.ClientOption) (*GCloudPubSub, error)
type Messager ¶
type Messager interface {
Publisher
Subscriber
Close()
}
type ParamError ¶
func (*ParamError) Error ¶
func (err *ParamError) Error() string
func (*ParamError) Root ¶
func (err *ParamError) Root() error
func (*ParamError) Status ¶
func (err *ParamError) Status() int
type ResizeOptions ¶
type ResizeOptions struct {
Width uint
CacheKey string // stable identity; hashed when present
Location string // fetch URL; hashed when CacheKey empty (legacy)
HashSum string
Encoding string
Prefix string
CacheControl string
IgnoreIfExists bool // skip fetch+resize+write when the object is warm + fresh
}
func (*ResizeOptions) DesiredEncoding ¶
func (opts *ResizeOptions) DesiredEncoding() string
func (*ResizeOptions) ObjectKey ¶
func (opts *ResizeOptions) ObjectKey() string
func (*ResizeOptions) PopulateHash ¶
func (opts *ResizeOptions) PopulateHash()
PopulateHash hashes CacheKey when present (gold-http path); else Location (legacy browser-url path, retained for the shared consumer).
type ResizeOptionsProcessed ¶
type ResizeOptionsProcessed struct {
ResizeOptions
URL *url.URL
Force bool
}
func NewResizeOptionsFromQuery ¶
func NewResizeOptionsFromQuery(m map[string][]string) (ResizeOptionsProcessed, error)
type Subscriber ¶
type Subscriber interface {
Subscribe(subj string, h func([]byte)) (Subscription, error)
}
type Subscription ¶
type Subscription interface {
Unsubscribe()
}
type SystemError ¶
func (*SystemError) Error ¶
func (err *SystemError) Error() string
func (*SystemError) Root ¶
func (err *SystemError) Root() error
func (*SystemError) Status ¶
func (err *SystemError) Status() int