41 lines
682 B
Go
41 lines
682 B
Go
|
package lorca
|
||
|
|
||
|
type Options struct {
|
||
|
Width int
|
||
|
Height int
|
||
|
ChromeArgs []string
|
||
|
}
|
||
|
|
||
|
type OptionsFunc func(opts *Options)
|
||
|
|
||
|
var DefaultChromeArgs = []string{
|
||
|
"--remote-allow-origins=*",
|
||
|
}
|
||
|
|
||
|
func NewOptions(funcs ...OptionsFunc) *Options {
|
||
|
opts := &Options{
|
||
|
Width: 800,
|
||
|
Height: 600,
|
||
|
ChromeArgs: DefaultChromeArgs,
|
||
|
}
|
||
|
|
||
|
for _, fn := range funcs {
|
||
|
fn(opts)
|
||
|
}
|
||
|
|
||
|
return opts
|
||
|
}
|
||
|
|
||
|
func WithWindowSize(width, height int) OptionsFunc {
|
||
|
return func(opts *Options) {
|
||
|
opts.Width = width
|
||
|
opts.Height = height
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func WithAdditionalChromeArgs(args ...string) OptionsFunc {
|
||
|
return func(opts *Options) {
|
||
|
opts.ChromeArgs = append(args, DefaultChromeArgs...)
|
||
|
}
|
||
|
}
|