1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-03-05 15:16:07 +02:00
ferret/cli/options.go

44 lines
750 B
Go
Raw Normal View History

2018-09-25 21:49:42 -04:00
package cli
import (
"context"
"github.com/MontFerret/ferret/pkg/drivers"
"github.com/MontFerret/ferret/pkg/drivers/cdp"
"github.com/MontFerret/ferret/pkg/drivers/http"
)
type Options struct {
Cdp string
Params map[string]interface{}
Proxy string
UserAgent string
ShowTime bool
}
func (opts Options) WithContext(ctx context.Context) (context.Context, error) {
var err error
ctx = drivers.WithDynamic(
ctx,
cdp.NewDriver(
cdp.WithAddress(opts.Cdp),
cdp.WithProxy(opts.Proxy),
cdp.WithUserAgent(opts.UserAgent),
),
)
if err != nil {
return ctx, err
}
ctx = drivers.WithStatic(
ctx,
http.NewDriver(
http.WithProxy(opts.Proxy),
http.WithUserAgent(opts.UserAgent),
),
)
return ctx, err
}