dims

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleDimsStatus

func HandleDimsStatus(config core.Config, w http.ResponseWriter, r *http.Request)

func Handler

func Handler(request RequestContext) error

func LegacyValues

func LegacyValues(u *url.URL) []string

LegacyValues returns the values named by _keys, in the order _keys lists them. This is the mod_dims rule. It covers only the parameters a caller opts in, so every other parameter stays open to tampering.

func SignedQuery

func SignedQuery(u *url.URL) string

SignedQuery returns the canonical form of every query parameter that takes part in the signature: each one written as name=value, percent-encoded and ordered by name. url.Values.Encode does both.

The name is part of the string, so moving a character from one parameter to the next changes it. The values alone do not: "ab" then "c" reads the same as "a" then "bc". Percent-encoding keeps a value from carrying a separator of its own.

Types

type Headers added in v0.5.0

type Headers interface {
	Etag() string
	LastModified() string
	Expires() string
	CacheControl() string
	EdgeControl() string
	ContentDisposition() string
}

type Request

type Request struct {
	URL                    *url.URL   // The URL of the http.
	ImageUrl               string     // The image URL that is being manipulated.
	SendContentDisposition bool       // Whether to send a Content-Disposition header.
	Download               bool       // Whether the caller asked for a download rather than inline.
	RawCommands            string     // The commands ('resize/100x100', 'strip/true/format/png', etc).
	Signature              string     // The signature of the request.
	SignedQuery            string     // Every signed query parameter, canonically encoded.
	LegacyParams           []string   // Values named by _keys, in _keys order. Legacy mode only.
	SourceImage            core.Image // The source image.
	// contains filtered or unexported fields
}

func NewRequest added in v0.5.0

func NewRequest(url *url.URL, cmds string, config core.Config) (*Request, error)

func (*Request) Commands

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

Commands returns the parsed command list. The result is kept, since this is called once while loading the image and again while processing it.

func (*Request) Config

func (r *Request) Config() core.Config

func (*Request) FetchImage

func (r *Request) FetchImage(timeout time.Duration) (*core.Image, error)

func (*Request) LoadImage added in v0.4.0

func (r *Request) LoadImage(sourceImage *core.Image) (*vips.ImageRef, error)

func (*Request) ProcessImage

func (r *Request) ProcessImage(image *vips.ImageRef, errorImage bool) (string, []byte, error)

ProcessImage will execute the commands on the image.

type RequestContext added in v0.5.0

type RequestContext interface {
	Headers
	Config() core.Config
	Validate() bool
	FetchImage(timeout time.Duration) (*core.Image, error)
	NotModified() bool
	SendNotModified() error
	LoadImage(image *core.Image) (*vips.ImageRef, error)
	ProcessImage(img *vips.ImageRef, strip bool) (string, []byte, error)
	SendImage(status int, imageFormat string, imageBlob []byte) error
}

Jump to

Keyboard shortcuts

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