-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
56 lines (48 loc) · 1.47 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
package simplegeoip
import (
"net/url"
"strconv"
"strings"
)
// Option adds parameters to the query.
type Option func(v url.Values)
var _ = []Option{
OptionOutputFormat("JSON"),
OptionIPAddress("8.8.8.8"),
OptionDomain("whoisxmlapi.com"),
OptionEmail("support@whoisxmlapi.com"),
OptionReverseIP(0),
}
// OptionOutputFormat sets Response output format JSON | XML. Default: JSON.
func OptionOutputFormat(outputFormat string) Option {
return func(v url.Values) {
v.Set("outputFormat", strings.ToUpper(outputFormat))
}
}
// OptionIPAddress sets IPv4 or IPv6 to search location by.
// If the parameter is not specified, then it defaults to client request's public IP address.
func OptionIPAddress(value string) Option {
return func(v url.Values) {
v.Set("ipAddress", value)
}
}
// OptionDomain sets the domain name to search location by.
// If the parameter is not specified, then 'ipAddress' will be used.
func OptionDomain(value string) Option {
return func(v url.Values) {
v.Set("domain", value)
}
}
// OptionEmail sets the email address or domain name to search location by its MX servers.
// If the parameter is not specified, then 'domain' will be used.
func OptionEmail(value string) Option {
return func(v url.Values) {
v.Set("email", value)
}
}
// OptionReverseIP sets the parameter for showing 5 domains associated with the IP address. Default: 1.
func OptionReverseIP(value int) Option {
return func(v url.Values) {
v.Set("reverseIp", strconv.Itoa(value))
}
}