httploader

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: Apache-2.0 Imports: 9 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.
	// If nil, http.DefaultTransport is used.
	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

	// 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
}

func New

func New(options ...Option) *HTTPLoader

func (*HTTPLoader) Load

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

type Option

type Option func(h *HTTPLoader)

func WithAllowedSources

func WithAllowedSources(hosts ...string) Option

func WithDefaultScheme

func WithDefaultScheme(scheme string) Option

func WithForwardAllHeaders

func WithForwardAllHeaders(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 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