forked from chromedp/pdlgen
/
domain.qtpl
28 lines (25 loc) · 947 Bytes
/
domain.qtpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{% import "github.com/chromedp/cdproto-gen/pdl" %}
{% func DomainManagerTemplate(domains []*pdl.Domain) %}
/*
Package domain helps executing cdproto commands.
*/
package domain
import (
"context"
)
// Domain executes a cdproto command against a chromedp context.
type Domain struct {
ctxWithExecutor context.Context // chromedp context
}
// Do makes a Domain that executes a cdproto command against a chromedp context.
// Set up arg `ctxWithExecutor` with `cdp.WithExecutor()` and `chromedp.FromContext()` beforehand.
func Do(ctxWithExecutor context.Context) Domain {
return Domain{ctxWithExecutor}
}
{% for _, domain := range domains %}
// {%s= domain.Domain.String() %} executes a cdproto command under {%s= domain.Domain.String() %} domain.
func (d Domain) {%s= domain.Domain.String() %}() {%s= domain.Domain.String() %} {
return {%s= domain.Domain.String() %}{d.ctxWithExecutor}
}
{% endfor %}
{% endfunc %}