Documentation ¶
Index ¶
- Constants
- Variables
- func ExportGIF(image *vips.ImageRef, imageOptions *ImageOptions) ([]byte, error)
- func ExportJPEG(image *vips.ImageRef, imageOptions *ImageOptions) ([]byte, error)
- func ExportPNG(image *vips.ImageRef, imageOptions *ImageOptions) ([]byte, error)
- func ExportWEBP(image *vips.ImageRef, imageOptions *ImageOptions) ([]byte, error)
- func FitImage(image *vips.ImageRef, imageOptions *ImageOptions) error
- func ImageType(name string) vips.ImageType
- func ImageTypeFromAccept(accept string) vips.ImageType
- func ImageTypeFromMimeType(mimeType string) vips.ImageType
- func MimeTypeFromImageType(code vips.ImageType) string
- func NewHandler(config *Config) *http.ServeMux
- func NewImageHandler(config *Config, handler http.Handler) http.Handler
- func PixelateImage(image *vips.ImageRef, imageOptions *ImageOptions) error
- func SmartCropImage(image *vips.ImageRef, imageOptions *ImageOptions) error
- type AuthMiddleware
- type Config
- type DefaultRouteHandler
- type DownloadedFile
- type HttpServer
- type ImageExport
- type ImageOperation
- type ImageOptions
- type ImageSource
- type ImageTransformHandler
- type LoggingMiddleware
- type ProcessedImage
- type ProxyHandler
- type SignatureMiddleware
- type SourceMiddleware
Constants ¶
View Source
const ( KB = 1024 MB = 1024 * KB )
View Source
const ( ParamOperations = "op" ParamWidth = "w" ParamHeight = "h" ParamQuality = "q" ParamStripMetadata = "strip" ParamFormat = "format" ParamPixelateFactor = "pixelatefactor" )
Allowed URL parameters
View Source
const SignatureParam = "s"
View Source
const UserAgent = "mediator"
Variables ¶
View Source
var ImageExportMap = map[vips.ImageType]ImageExport{ vips.ImageTypeJPEG: ExportJPEG, vips.ImageTypePNG: ExportPNG, vips.ImageTypeWEBP: ExportWEBP, vips.ImageTypeGIF: ExportGIF, }
View Source
var ImageOperationsMap = map[string]ImageOperation{ "fit": FitImage, "smartcrop": SmartCropImage, "pixelate": PixelateImage, }
Functions ¶
func ExportJPEG ¶
func ExportJPEG(image *vips.ImageRef, imageOptions *ImageOptions) ([]byte, error)
func ExportWEBP ¶
func ExportWEBP(image *vips.ImageRef, imageOptions *ImageOptions) ([]byte, error)
func ImageTypeFromAccept ¶
func ImageTypeFromMimeType ¶
func MimeTypeFromImageType ¶
func NewHandler ¶
func PixelateImage ¶
func PixelateImage(image *vips.ImageRef, imageOptions *ImageOptions) error
func SmartCropImage ¶
func SmartCropImage(image *vips.ImageRef, imageOptions *ImageOptions) error
Types ¶
type AuthMiddleware ¶
type AuthMiddleware struct {
// contains filtered or unexported fields
}
func NewAuthMiddleware ¶
func NewAuthMiddleware(config *Config, next http.Handler) *AuthMiddleware
func (*AuthMiddleware) ServeHTTP ¶
func (h *AuthMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Config ¶
type DefaultRouteHandler ¶
type DefaultRouteHandler struct{}
func NewDefaultRouteHandler ¶
func NewDefaultRouteHandler() *DefaultRouteHandler
func (*DefaultRouteHandler) ServeHTTP ¶
func (h *DefaultRouteHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type DownloadedFile ¶
type DownloadedFile struct { OriginalURL string FinalURL string ContentType string ContentLength int StatusCode int Buffer bytes.Buffer }
func DownloadFile ¶
func ProxyFile ¶
func ProxyFile(url string, maxSize int, requestTimeout time.Duration, r *http.Request, w http.ResponseWriter) (*DownloadedFile, error)
Download file and stream it back as response
func (*DownloadedFile) Size ¶
func (f *DownloadedFile) Size() int
type HttpServer ¶
type HttpServer struct {
// contains filtered or unexported fields
}
func NewHttpServer ¶
func NewHttpServer(config *Config, handler http.Handler) *HttpServer
func (*HttpServer) Start ¶
func (s *HttpServer) Start()
func (*HttpServer) Stop ¶
func (s *HttpServer) Stop()
type ImageExport ¶
type ImageExport func(*vips.ImageRef, *ImageOptions) ([]byte, error)
type ImageOperation ¶
type ImageOperation func(*vips.ImageRef, *ImageOptions) error
type ImageOptions ¶
type ImageOptions struct { Operations []string Width int Height int Quality int StripMetadata bool Format vips.ImageType RequestedFormat string AutoRotate bool PixelateFactor int Page int }
func NewImageOptionsFromRequest ¶
func NewImageOptionsFromRequest(r *http.Request) *ImageOptions
type ImageSource ¶
func NewImageSourceFromHttpRequest ¶
func NewImageSourceFromHttpRequest(r *http.Request, config *Config) (*ImageSource, error)
func (*ImageSource) URLWithQueryString ¶
func (imageSource *ImageSource) URLWithQueryString(r *http.Request) string
type ImageTransformHandler ¶
type ImageTransformHandler struct {
// contains filtered or unexported fields
}
func NewImageTransformHandler ¶
func NewImageTransformHandler(config *Config) *ImageTransformHandler
func (*ImageTransformHandler) ServeHTTP ¶
func (h *ImageTransformHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type LoggingMiddleware ¶
type LoggingMiddleware struct {
// contains filtered or unexported fields
}
func NewLoggingMiddleware ¶
func NewLoggingMiddleware(next http.Handler) *LoggingMiddleware
func (*LoggingMiddleware) ServeHTTP ¶
func (h *LoggingMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ProcessedImage ¶
func ExportImage ¶
func ExportImage(image *vips.ImageRef, imageOptions *ImageOptions) (*ProcessedImage, error)
func TransformImage ¶
func TransformImage(imageBytes []byte, imageOptions *ImageOptions) (*ProcessedImage, error)
type ProxyHandler ¶
type ProxyHandler struct {
// contains filtered or unexported fields
}
func NewProxyHandler ¶
func NewProxyHandler(config *Config) *ProxyHandler
func (*ProxyHandler) ServeHTTP ¶
func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type SignatureMiddleware ¶
type SignatureMiddleware struct {
// contains filtered or unexported fields
}
func NewSignatureMiddleware ¶
func NewSignatureMiddleware(secret string, next http.Handler) *SignatureMiddleware
func (*SignatureMiddleware) ServeHTTP ¶
func (h *SignatureMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
type SourceMiddleware ¶
type SourceMiddleware struct {
// contains filtered or unexported fields
}
func NewSourceMiddleware ¶
func NewSourceMiddleware(config *Config, next http.Handler) *SourceMiddleware
func (*SourceMiddleware) ServeHTTP ¶
func (h *SourceMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
Source Files ¶
- auth_middleware.go
- config.go
- default_route_handler.go
- download.go
- handler.go
- http_request_utils.go
- http_response_writer.go
- http_server.go
- image_export.go
- image_operations.go
- image_options.go
- image_source.go
- image_transform_handler.go
- image_type.go
- logging_middleware.go
- proxy_handler.go
- signature_middleware.go
- source_middleware.go
Click to show internal directories.
Click to hide internal directories.