Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateImageProxyURL ¶ added in v0.245.0
GenerateImageProxyURL generates an image proxy URL for the given remote image URL. If a proxy URL cannot be generated, the original remote image URL is returned.
func HandleImage ¶
func HandleImage(cache ImageCache, opts ...Option) http.HandlerFunc
HandleImage is handler that will attempt to proxy an image through the image proxy. It will fetch, store and retrieve the image from the cache as needed.
Types ¶
type ImageCache ¶ added in v0.235.0
type Option ¶ added in v0.245.0
type Option func(*handler)
Option configures the image handler.
func WithSignatureVerifier ¶ added in v0.245.0
func WithSignatureVerifier(v SignatureVerifier) Option
WithSignatureVerifier enables signature verification of incoming requests. Strongly recommended when no image proxy prefix is configured, otherwise the handler is an open proxy.
type SignatureVerifier ¶ added in v0.245.0
SignatureVerifier checks the signature segment against the signed path. path is everything after the signature, including the leading slash (i.e. "/<options...>/<encoded url>"). Return true if the signature is valid. See NewSignatureVerifier for an imgproxy-compatible implementation.
func NewSignatureVerifier ¶ added in v0.245.0
func NewSignatureVerifier(keyHex, saltHex string) (SignatureVerifier, error)
NewSignatureVerifier returns a SignatureVerifier compatible with imgproxy's URL signing:
signature = base64url_raw(HMAC-SHA256(key, salt || path))
keyHex and saltHex are the hex-encoded values of IMGPROXY_KEY and IMGPROXY_SALT. path is the part of the URL after the signature, including the leading slash. Truncated signatures (IMGPROXY_SIGNATURE_SIZE) are supported.