mirror of
https://github.com/MontFerret/ferret.git
synced 2025-01-18 03:22:02 +02:00
45 lines
676 B
Go
45 lines
676 B
Go
package cdp
|
|
|
|
type (
|
|
Options struct {
|
|
proxy string
|
|
userAgent string
|
|
address string
|
|
}
|
|
|
|
Option func(opts *Options)
|
|
)
|
|
|
|
const DefaultAddress = "http://127.0.0.1:9222"
|
|
|
|
func newOptions(setters []Option) *Options {
|
|
opts := new(Options)
|
|
opts.address = DefaultAddress
|
|
|
|
for _, setter := range setters {
|
|
setter(opts)
|
|
}
|
|
|
|
return opts
|
|
}
|
|
|
|
func WithAddress(address string) Option {
|
|
return func(opts *Options) {
|
|
if address != "" {
|
|
opts.address = address
|
|
}
|
|
}
|
|
}
|
|
|
|
func WithProxy(address string) Option {
|
|
return func(opts *Options) {
|
|
opts.proxy = address
|
|
}
|
|
}
|
|
|
|
func WithUserAgent(value string) Option {
|
|
return func(opts *Options) {
|
|
opts.userAgent = value
|
|
}
|
|
}
|