renderer

package
v0.0.0-...-dfdb652 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chrome

type Chrome struct {
	Debug    bool
	Args     map[string]string
	Resolver ChromeResolver
}

func (*Chrome) Render

func (chrome *Chrome) Render(
	ctx context.Context,
	url string,
	opts Opts,
) (c []byte, err error)

type ChromeResolver

type ChromeResolver interface {
	BrowserWebSocketURL(ctx context.Context) (string, error)
}

ChromeResolver define interface to retrieve browser websocket url.

func NewChromeResolver

func NewChromeResolver(addr string) (ChromeResolver, error)

type ChromeResolverAPI

type ChromeResolverAPI struct {
	Addr   string
	Client *http.Client
}

ChromeResolverAPI uses Chrome debug API to retrieve WebSocket URL.

func (*ChromeResolverAPI) BrowserWebSocketURL

func (r *ChromeResolverAPI) BrowserWebSocketURL(ctx context.Context) (string, error)

type ChromeResolverStatic

type ChromeResolverStatic struct {
	WebSocketURL string
}

ChromeResolverStatic accepts WS connection string and resolve to it everytime.

func (*ChromeResolverStatic) BrowserWebSocketURL

func (r *ChromeResolverStatic) BrowserWebSocketURL(ctx context.Context) (string, error)

type Opts

type Opts struct {
	// Viewport width in pixels of the browser render. Default is 1680
	Width int

	// Viewport height in pixels of the browser render. Default is 867
	Height int

	// Scale from 0
	Scale float64

	// Format of image
	Format internal.ImageFormat

	// Quality of image
	Quality int

	// Delay before take screenshot in seconds
	Delay time.Duration

	// Capture full page screenshot
	FullPage bool

	// Set this parameter to true to scroll through the entire page before capturing a screenshot.
	ScrollPage bool

	// Clip of viewport.
	// All fields is required.
	Clip OptsClip
}

func (Opts) Hash

func (opts Opts) Hash() string

func (*Opts) Validate

func (opts *Opts) Validate() error

type OptsClip

type OptsClip struct {
	X, Y          *float64
	Width, Height *float64
}

func (*OptsClip) IsSet

func (optsClip *OptsClip) IsSet() bool

func (*OptsClip) SetHeight

func (optsClip *OptsClip) SetHeight(v float64)

func (*OptsClip) SetWidth

func (optsClip *OptsClip) SetWidth(v float64)

func (*OptsClip) SetX

func (optsClip *OptsClip) SetX(v float64)

func (*OptsClip) SetY

func (optsClip *OptsClip) SetY(v float64)

func (OptsClip) Validate

func (optsClip OptsClip) Validate() error

type Renderer

type Renderer interface {
	Render(ctx context.Context, url string, opts Opts) ([]byte, error)
}

Jump to

Keyboard shortcuts

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