mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-14 11:23:02 +02:00
minor tweak in runtime.Options
This commit is contained in:
parent
17b52fdfd5
commit
e0874d25f7
@ -22,7 +22,7 @@ type (
|
||||
Option func(*Options)
|
||||
)
|
||||
|
||||
func newOptions() *Options {
|
||||
func NewOptions() *Options {
|
||||
return &Options{
|
||||
cdp: "http://0.0.0.0:9222",
|
||||
params: make(map[string]core.Value),
|
||||
@ -83,7 +83,15 @@ func WithLogLevel(lvl logging.Level) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func (opts *Options) withContext(parent context.Context) context.Context {
|
||||
func (opts *Options) Apply(setters ...Option) *Options {
|
||||
for _, setter := range setters {
|
||||
setter(opts)
|
||||
}
|
||||
|
||||
return opts
|
||||
}
|
||||
|
||||
func (opts *Options) WithContext(parent context.Context) context.Context {
|
||||
ctx := core.ParamsWith(parent, opts.params)
|
||||
ctx = logging.WithContext(ctx, opts.logging)
|
||||
ctx = env.WithContext(ctx, env.Environment{
|
||||
|
@ -33,13 +33,7 @@ func (p *Program) Run(ctx context.Context, setters ...Option) ([]byte, error) {
|
||||
|
||||
defer closeFn()
|
||||
|
||||
opts := newOptions()
|
||||
|
||||
for _, setter := range setters {
|
||||
setter(opts)
|
||||
}
|
||||
|
||||
ctx = opts.withContext(ctx)
|
||||
ctx = NewOptions().Apply(setters...).WithContext(ctx)
|
||||
ctx = html.WithDynamicDriver(ctx)
|
||||
ctx = html.WithStaticDriver(ctx)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user