arcast/pkg/browser/lorca/options.go

41 lines
678 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{
2024-01-21 14:59:19 +01:00
Width: 0,
Height: 0,
2023-12-13 20:07:22 +01:00
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...)
}
}