-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
78 lines (67 loc) · 1.99 KB
/
options.go
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package whoisapi
import (
"net/url"
"strconv"
"strings"
)
// Option adds parameters to the query
type Option func(v url.Values)
var _ = []Option{
OptionOutputFormat("JSON"),
OptionPreferFresh(0),
OptionDA(0),
OptionIP(0),
OptionIPWhois(0),
OptionCheckProxyData(0),
OptionThinWhois(0),
OptionIgnoreRawTexts(0),
}
// OptionOutputFormat to set Response output format JSON | XML
func OptionOutputFormat(outputFormat string) Option {
return func(v url.Values) {
v.Set("outputFormat", strings.ToUpper(outputFormat))
}
}
// OptionPreferFresh to set parameter for getting the latest WHOIS record even if it's incomplete
func OptionPreferFresh(value int) Option {
return func(v url.Values) {
v.Set("preferFresh", strconv.Itoa(value))
}
}
// OptionDA to set parameter for a quick check on domain availability
func OptionDA(value int) Option {
return func(v url.Values) {
v.Set("da", strconv.Itoa(value))
}
}
// OptionIP to set parameter for returning IPs for the domain name
func OptionIP(value int) Option {
return func(v url.Values) {
v.Set("ip", strconv.Itoa(value))
}
}
// OptionIPWhois to set parameter for returning the WHOIS record for the hosting IP
// if the WHOIS record for the tld of the input domain is not supported
func OptionIPWhois(value int) Option {
return func(v url.Values) {
v.Set("ipWhois", strconv.Itoa(value))
}
}
// OptionCheckProxyData to set parameter for fetching proxy/WHOIS guard data, if it exists
func OptionCheckProxyData(value int) Option {
return func(v url.Values) {
v.Set("checkProxyData", strconv.Itoa(value))
}
}
// OptionThinWhois to set parameter for returning WHOIS data from registry only, without fetching data from registrar
func OptionThinWhois(value int) Option {
return func(v url.Values) {
v.Set("thinWhois", strconv.Itoa(value))
}
}
// OptionIgnoreRawTexts to set parameter for stripping all raw text from the output
func OptionIgnoreRawTexts(value int) Option {
return func(v url.Values) {
v.Set("ignoreRawTexts", strconv.Itoa(value))
}
}