imageserver: github.com/pierrre/imageserver Index | Files | Directories

package imageserver

import "github.com/pierrre/imageserver"

Package imageserver provides an Image server toolkit.

Index

Package Files

handler.go image.go params.go server.go

Constants

const (
    // ImageFormatMaxLen is the maximum length for the Image's format.
    ImageFormatMaxLen = 1 << 8 // 256 B
    // ImageDataMaxLen is the maximum length for the Image's data.
    ImageDataMaxLen = 1 << 30 // 1 GiB
)

type Handler Uses

type Handler interface {
    Handle(*Image, Params) (*Image, error)
}

Handler handles an Image and returns an Image.

type HandlerFunc Uses

type HandlerFunc func(*Image, Params) (*Image, error)

HandlerFunc is a Handler func.

func (HandlerFunc) Handle Uses

func (f HandlerFunc) Handle(im *Image, params Params) (*Image, error)

Handle implements Handler.

type HandlerServer Uses

type HandlerServer struct {
    Server
    Handler Handler
}

HandlerServer is a Server implementation that calls a Handler.

func (*HandlerServer) Get Uses

func (srv *HandlerServer) Get(params Params) (*Image, error)

Get implements Server.

type Image Uses

type Image struct {
    // Format is the format used to encode the image.
    //
    // e.g. png, jpeg, bmp, gif, ...
    Format string

    // Data contains the raw data of the encoded image.
    Data []byte
}

Image is a raw image.

Binary encoding:

- Format length (uint32)
- Format (string)
- Data length (uint32)
- Data([]byte)

Numbers are encoded using little-endian order.

func (*Image) MarshalBinary Uses

func (im *Image) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*Image) UnmarshalBinary Uses

func (im *Image) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

It copies data then call UnmarshalBinaryNoCopy().

func (*Image) UnmarshalBinaryNoCopy Uses

func (im *Image) UnmarshalBinaryNoCopy(data []byte) error

UnmarshalBinaryNoCopy is like encoding.BinaryUnmarshaler but does no copy.

The caller must not reuse data after that.

type ImageError Uses

type ImageError struct {
    Message string
}

ImageError is an Image error.

func (*ImageError) Error Uses

func (err *ImageError) Error() string

type ParamError Uses

type ParamError struct {
    Param   string // Nested param path uses "." as separator
    Message string
}

ParamError is an error for a param.

func (*ParamError) Error Uses

func (err *ParamError) Error() string

type Params Uses

type Params map[string]interface{}

Params are params used in imageserver.

This is a wrapper around map[string]interface{} and provides utility methods. It should only contains basic Go types values (string, int float64, ...) or nested Params.

Getter methods return a *ParamError if the key does not exist or the type does not match.

func (Params) Copy Uses

func (params Params) Copy() Params

Copy returns a deep copy of the Params.

func (Params) Empty Uses

func (params Params) Empty() bool

Empty returns true if params is empty and false otherwise.

func (Params) Get Uses

func (params Params) Get(key string) (interface{}, error)

Get returns the value for the key.

func (Params) GetBool Uses

func (params Params) GetBool(key string) (bool, error)

GetBool returns the bool value for the key.

func (Params) GetFloat Uses

func (params Params) GetFloat(key string) (float64, error)

GetFloat returns the float64 value for the key.

func (Params) GetInt Uses

func (params Params) GetInt(key string) (int, error)

GetInt returns the int value for the key.

func (Params) GetInt64 Uses

func (params Params) GetInt64(key string) (int64, error)

GetInt64 returns the int64 value for the key.

func (Params) GetParams Uses

func (params Params) GetParams(key string) (Params, error)

GetParams returns the Params value for the key.

func (Params) GetString Uses

func (params Params) GetString(key string) (string, error)

GetString returns the string value for the key.

func (Params) Has Uses

func (params Params) Has(key string) bool

Has returns true if the key exists and false otherwise.

func (Params) Keys Uses

func (params Params) Keys() []string

Keys returns the keys.

func (Params) Len Uses

func (params Params) Len() int

Len returns the length.

func (Params) Set Uses

func (params Params) Set(key string, value interface{})

Set sets the value for the key.

func (Params) String Uses

func (params Params) String() string

String returns the string representation.

Keys are sorted alphabetically.

type Server Uses

type Server interface {
    Get(Params) (*Image, error)
}

Server serves an Image.

func NewLimitServer Uses

func NewLimitServer(s Server, limit int) Server

NewLimitServer creates a new Server that limits the number of concurrent executions.

It uses a buffered channel to limit the number of concurrent executions.

type ServerFunc Uses

type ServerFunc func(Params) (*Image, error)

ServerFunc is a Server func.

func (ServerFunc) Get Uses

func (f ServerFunc) Get(params Params) (*Image, error)

Get implements Server.

Directories

PathSynopsis
cachePackage cache provides a base for an Image cache.
cache/filePackage file provides a disk based cache.
cache/groupcachePackage groupcache provides a groupcache imageserver.Server implementation.
cache/memcachePackage memcache provides a Memcache imageserver/cache.Cache implementation.
cache/memoryPackage memory provides an in-memory imageserver/cache.Cache implementation.
cache/redisPackage redis provides a Redis imageserver/cache.Cache implementation.
cache/_testPackage _test provides utilities for imageserver/cache.Cache testing.
examples/advancedPackage advanced provides an advanced example.
examples/cachePackage cache provides a cache example.
examples/groupcachePackage advanced provides a groupcache example.
examples/httpsourcePackage httpsource provides a HTTP Source example.
examples/simplePackage simple provides a simple example.
graphicsmagickPackage graphicsmagick provides a GraphicsMagick imageserver.Handler implementation.
httpPackage http provides a net/http.Handler implementation that wraps a imageserver.Server.
http/cropPackage crop provides a imageserver/http.Parser implementation for imageserver/image/crop.Processor.
http/gammaPackage gamma provides a imageserver/http.Parser implementation for imageserver/image/gamma.CorrectionProcessor.
http/giftPackage gift provides imageserver/http.Parser implementations for imageserver/image/gift.
http/graphicsmagickPackage graphicsmagick provides a imageserver/http.Parser implementation for imageserver/graphicsmagick.Handler.
http/imagePackage image provides imageserver/http.Parser implementations for imageserver/image.
http/nfntresizePackage nfntresize provides a imageserver/http.Parser implementation for imageserver/image/nfntresize.Processor.
imagePackage image provides a bridge to the Go "image" package.
image/bmpPackage bmp provides a BMP imageserver/image.Encoder implementation.
image/cropPackage crop provides a imageserver/image.Processor implementation that allows to crop Image.
image/gammaPackage gamma provides gamma imageserver/image.Processor implementations.
image/gifPackage gif provides GIF imageserver/image.Encoder|Processor and imageserver.Handler implementations.
image/giftPackage gift provides imageserver/image.Processor implementations for GIFT.
image/internalPackage internal provides utilities functions used in the image package.
image/jpegPackage jpeg provides a JPEG imageserver/image.Encoder implementation.
image/nfntresizePackage nfntresize provides a nfnt/resize imageserver/image.Processor implementation.
image/pngPackage png provides a PNG imageserver/image.Encoder implementation.
image/_testPackage _test provides utilities for imageserver/image.Encoder testing.
image/tiffPackage tiff provides a TIFF imageserver/image.Encoder implementation.
sourcePackage source provides a imageserver.Server implementation that forwards calls to the underlying Server with only the "source" param.
source/filePackage file provides a imageserver.Server implementation that get the Image from a file.
source/httpPackage http provides a imageserver.Server implementation that gets the Image from an HTTP URL.

Package imageserver imports 5 packages (graph) and is imported by 105 packages. Updated 2018-09-06. Refresh now. Tools for package owners.