httploader

package
v0.8.22 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPLoader

type HTTPLoader struct {
	// The Transport used to request images, default http.DefaultTransport.
	Transport http.RoundTripper

	// ForwardHeaders copy request headers to image request headers
	ForwardHeaders []string

	// OverrideHeaders override image request headers
	OverrideHeaders map[string]string

	// AllowedSources list of host names allowed to load from,
	// supports glob patterns such as *.google.com
	AllowedSources []string

	// Accept set request Accept and validate response Content-Type header
	Accept string

	// MaxAllowedSize maximum bytes allowed for image
	MaxAllowedSize int

	// DefaultScheme default image URL scheme
	DefaultScheme string

	// UserAgent default user agent for image request.
	// Can be overridden by ForwardHeaders and OverrideHeaders
	UserAgent string
	// contains filtered or unexported fields
}

func New

func New(options ...Option) *HTTPLoader

func (*HTTPLoader) Load

func (h *HTTPLoader) Load(r *http.Request, image string) (*imagor.Blob, error)

type Option

type Option func(h *HTTPLoader)

func WithAccept added in v0.7.5

func WithAccept(contentType string) Option

func WithAllowedSources

func WithAllowedSources(hosts ...string) Option

func WithDefaultScheme

func WithDefaultScheme(scheme string) Option

func WithForwardClientHeaders added in v0.8.15

func WithForwardClientHeaders(enabled bool) Option

func WithForwardHeaders

func WithForwardHeaders(headers ...string) Option

func WithInsecureSkipVerifyTransport

func WithInsecureSkipVerifyTransport(enabled bool) Option

func WithMaxAllowedSize

func WithMaxAllowedSize(maxAllowedSize int) Option

func WithOverrideHeader

func WithOverrideHeader(name, value string) Option

func WithProxyTransport added in v0.7.3

func WithProxyTransport(proxyURLs, hosts string) Option

func WithTransport

func WithTransport(transport http.RoundTripper) Option

func WithUserAgent

func WithUserAgent(userAgent string) Option

Jump to

Keyboard shortcuts

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