Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultImageDecode(r io.Reader) (image.Image, error)
- func GcfResize(ctx context.Context, m PubSubMessage) error
- func GetImage(url string) ([]byte, string, error)
- func ImageToBytes(i image.Image, hint string, quality int) (*bytes.Buffer, error)
- func NewGCloudLogger(project, name string, opts ...option.ClientOption) (*logging.Client, *logger.Google, error)
- func ReaderToImage(r io.ReadSeeker, hint string) (image.Image, 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 PubSubMessage
- type Publisher
- type ResizeOptions
- type ResizeOptionsProcessed
- type RootError
- type Subscriber
- type Subscription
- type SystemError
- type WriteInfo
Constants ¶
View Source
const MaxImageDimension = 4096
View Source
const ResizeTopic = "asset-delivery-resize"
PubSub topic for sending and receiving resize request
Variables ¶
View Source
var ( ErrFileNotHandled = errors.New("file type not handled") ErrInvalidBounds = errors.New("invalid image bounds") )
View Source
var ErrNoFile = errors.New("no file")
Functions ¶
func GcfResize ¶
func GcfResize(ctx context.Context, m PubSubMessage) error
GcfResize is meant to run on Google Cloud Functions
func ImageToBytes ¶
func NewGCloudLogger ¶
func ReaderToImage ¶
Reader to image will try to read the image
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 PubSubMessage ¶
type PubSubMessage struct {
Data []byte `json:"data,omitempty"`
}
PubSubMessage is the payload of a Pub/Sub event. Data is strictly ResizeOptions. See the documentation for more details: https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage
type ResizeOptions ¶
type ResizeOptions struct { Width uint Location string HashSum string Encoding string Prefix string CacheControl string }
func (*ResizeOptions) DesiredEncoding ¶
func (opts *ResizeOptions) DesiredEncoding() string
func (*ResizeOptions) ObjectKey ¶
func (opts *ResizeOptions) ObjectKey() string
func (*ResizeOptions) PopulateHash ¶
func (opts *ResizeOptions) PopulateHash()
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
Source Files ¶
Click to show internal directories.
Click to hide internal directories.