arcast/pkg/browser/lorca/options.go

41 lines
682 B
Go
Raw Permalink Normal View History

2023-12-13 20:07:22 +01:00
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...)
}
}