Documentation ¶
Index ¶
- Constants
- type Cacheable
- type Config
- type Configuration
- type Entry
- type GridfsStorage
- func (g GridfsStorage) FindImageByParentFilename(namespace, filename string, entry *Entry) (Cacheable, error)
- func (g GridfsStorage) FindImageByParentID(namespace, id string, entry *Entry) (Cacheable, error)
- func (g GridfsStorage) IsValidID(id string) bool
- func (g GridfsStorage) StoreChildImage(database, imageFormat string, reader io.Reader, imageWidth, imageHeight int, ...) (Cacheable, error)
- type Identity
- type MetaContainer
- type ReadSeekCloser
- type Server
- type Storage
Constants ¶
const (
//ImageCacheDuration caching time for images
ImageCacheDuration = 315360000
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cacheable ¶
type Cacheable interface { CacheIdentifier() string LastModified() time.Time Data() ReadSeekCloser Name() string }
Cacheable is an interface for caching
type Config ¶
type Config struct {
AllowedEntries []Entry `json:allowedEntries`
}
Config contains entries for possible image configurations
func NewConfigFromBytes ¶
NewConfigFromBytes generates a new config object by a byte stream
func NewConfigFromFile ¶
NewConfigFromFile returns an Config object from a given file.
type Configuration ¶
Configuration is a wrapper object for request parameters.
func CreateConfigurationFromVars ¶
CreateConfigurationFromVars validate all necessary request parameters
type Entry ¶
type Entry struct { Name string `json:name` Width int64 `json:width` Height int64 `json:height` Type paint.ResizeType `json:type` }
Entry is one allowed image configuration
type GridfsStorage ¶
type GridfsStorage struct {
Connection *mgo.Session
}
GridfsStorage will be made private
func (GridfsStorage) FindImageByParentFilename ¶
func (g GridfsStorage) FindImageByParentFilename(namespace, filename string, entry *Entry) (Cacheable, error)
FindImageByParentFilename returns either the resized image that actually exists, or the original if entry is nil
func (GridfsStorage) FindImageByParentID ¶
func (g GridfsStorage) FindImageByParentID(namespace, id string, entry *Entry) (Cacheable, error)
FindImageByParentID returns either the resized image that actually exists, or the original if entry is nil
func (GridfsStorage) IsValidID ¶
func (g GridfsStorage) IsValidID(id string) bool
IsValidID will return true if id is a valid bson object id
type Identity ¶
type Identity interface {
ID() interface{}
}
Identity returns a unique identifer for its implementor
type MetaContainer ¶
type MetaContainer interface {
Meta() map[string]interface{}
}
MetaContainer is an optional interface that can be implemented to return optional metadata
type ReadSeekCloser ¶
type ReadSeekCloser interface { io.ReadCloser io.Seeker }
ReadSeekCloser implements io.ReadCloser and io.Seeker
type Server ¶
Server interface for our server
func NewImageServer ¶
NewImageServer returns a new image server
type Storage ¶
type Storage interface { StoreChildImage(database, imageFormat string, imageData io.Reader, imageWidth, imageHeight int, original Cacheable, entry *Entry) (Cacheable, error) FindImageByParentID(namespace, id string, entry *Entry) (Cacheable, error) FindImageByParentFilename(namespace, filename string, entry *Entry) (Cacheable, error) IsValidID(id string) bool }
Storage interface can be implemented to use the image server with any backend you like
func NewGridfsStorage ¶
NewGridfsStorage returns a new gridfs storage provider