mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-16 11:37:36 +02:00
34c8c02258
* Externalized HTML drivers * Fixed unit tests * Updated logging * Added support to set default driver * Updated GetIn and SetIn helpers
40 lines
720 B
Go
40 lines
720 B
Go
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) {
|
|
ctx = drivers.WithContext(
|
|
ctx,
|
|
http.NewDriver(
|
|
http.WithProxy(opts.Proxy),
|
|
http.WithUserAgent(opts.UserAgent),
|
|
),
|
|
drivers.AsDefault(),
|
|
)
|
|
|
|
ctx = drivers.WithContext(
|
|
ctx,
|
|
cdp.NewDriver(
|
|
cdp.WithAddress(opts.Cdp),
|
|
cdp.WithProxy(opts.Proxy),
|
|
cdp.WithUserAgent(opts.UserAgent),
|
|
),
|
|
)
|
|
|
|
return ctx, nil
|
|
}
|