dims

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleDimsStatus

func HandleDimsStatus(config EnvironmentConfig, debug bool, dev bool, w http.ResponseWriter, r *http.Request)

func Handler

func Handler(kernel Kernel, config Config, w http.ResponseWriter)

Types

type Command

type Command struct {
	Name string
	Args string
}

type Commands added in v0.3.0

type Commands interface {
	Commands(cmds string) []Command
}

type Config

type Config struct {
	DevelopmentMode bool
	DebugMode       bool
	EtagAlgorithm   string
	EnvironmentConfig
}

type EdgeControl

type EdgeControl struct {
	DownstreamTtl int `env:"DIMS_EDGE_CONTROL_DOWNSTREAM_TTL" envDefault:"0"`
}

type Error

type Error struct {
	Image      string `env:"DIMS_ERROR_IMAGE" envDefault:""`
	Background string `env:"DIMS_ERROR_BACKGROUND" envDefault:"#5ADAFD"`
}

type ErrorImageGenerator added in v0.3.0

type ErrorImageGenerator interface {
	GenerateErrorImage(w http.ResponseWriter, status int, message string)
}

type Image

type Image struct {
	Bytes        []byte // The downloaded image.
	Size         int    // The original image size in bytes.
	Format       string // The original image format.
	Status       int    // The HTTP status code of the downloaded image.
	CacheControl string // The cache headers from the downloaded image.
	EdgeControl  string // The edge control headers from the downloaded image.
	LastModified string // The last modified header from the downloaded image.
	Etag         string // The etag header from the downloaded image.
}

type ImageProcessor added in v0.3.0

type ImageProcessor interface {
	ProcessImage() (string, []byte, error)
}

type Kernel

type Kernel interface {
	ValidateSignature() bool
	FetchImage() error
	ProcessImage() (string, []byte, error)
	ProcessCommand(command Command) error
	SendHeaders(w http.ResponseWriter)
	SendImage(w http.ResponseWriter, status int, imageType string, imageBlob []byte) error
	SendError(w http.ResponseWriter, status int, message string)
}

type Options

type Options struct {
	StripMetadata      bool `env:"DIMS_STRIP_METADATA" envDefault:"true"`
	IncludeDisposition bool `env:"DIMS_INCLUDE_DISPOSITION" envDefault:"false"`
}

type OriginCacheControl

type OriginCacheControl struct {
	UseOrigin bool `env:"DIMS_CACHE_CONTROL_USE_ORIGIN" envDefault:"false"`
	Min       int  `env:"DIMS_CACHE_CONTROL_MIN" envDefault:"0"`
	Max       int  `env:"DIMS_CACHE_CONTROL_MAX" envDefault:"0"`
	Default   int  `env:"DIMS_CACHE_CONTROL_DEFAULT" envDefault:"31536000"`
	Error     int  `env:"DIMS_CACHE_CONTROL_ERROR" envDefault:"60"`
}

type OutputFormat

type OutputFormat struct {
	OutputFormat string   `env:"DIMS_OUTPUT_FORMAT"`
	Exclude      []string `env:"DIMS_OUTPUT_FORMAT_EXCLUDE"`
}

type Request

type Request struct {
	Id                     string // The hash of the request -> hash(clientId + commands + imageUrl).
	Signature              string // The signature of the request.
	Config                 Config // The global configuration.
	ClientId               string // The client ID of this request.
	ImageUrl               string // The image URL that is being manipulated.
	SendContentDisposition bool   // The content disposition of the request.
	RawCommands            string // The commands ('resize/100x100', 'strip/true/format/png', etc).
	Error                  bool   // Whether the error image is being served.
	SourceImage            Image  // The source image.
}

func (*Request) Commands

func (r *Request) Commands() []Command

func (*Request) FetchImage

func (r *Request) FetchImage() error

FetchImage downloads the image from the given URL.

func (*Request) SendError

func (r *Request) SendError(w http.ResponseWriter, status int, message string)

func (*Request) SendHeaders

func (r *Request) SendHeaders(w http.ResponseWriter)

func (*Request) SendImage

func (r *Request) SendImage(w http.ResponseWriter, status int, imageFormat string, imageBlob []byte) error

type Signing

type Signing struct {
	SigningKey    string `env:"DIMS_SIGNING_KEY,notEmpty"`
	EtagAlgorithm string
}

type Timeout

type Timeout struct {
	Download int `env:"DIMS_DOWNLOAD_TIMEOUT" envDefault:"3000"`
}

type UrlSigner added in v0.3.0

type UrlSigner interface {
	SignUrl() (string, error)
	ImageUrl() string
	Commands() []Command
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL