6
6
"context"
7
7
"errors"
8
8
"net/http"
9
- "net/url"
10
9
"strconv"
11
10
"time"
12
11
@@ -21,11 +20,6 @@ const (
21
20
rateLimitSleep = 1100
22
21
)
23
22
24
- var allowedRegionsHostMap = map [string ]string {
25
- "eu" : "https://api.eu.sendgrid.com" ,
26
- "global" : "https://api.sendgrid.com" ,
27
- }
28
-
29
23
type options struct {
30
24
Auth string
31
25
Endpoint string
@@ -61,50 +55,6 @@ func requestNew(options options) rest.Request {
61
55
}
62
56
}
63
57
64
- // extractEndpoint extracts the endpoint from a baseURL
65
- func extractEndpoint (link string ) (string , error ) {
66
- parsedURL , err := url .Parse (link )
67
- if err != nil {
68
- return "" , err
69
- }
70
-
71
- return parsedURL .Path , nil
72
- }
73
-
74
- // SetHost changes the baseURL of the request with the host passed
75
- /*
76
- * This allows support for global and eu regions only. This set will likely expand in the future.
77
- * Global should be the default
78
- * Global region means the message should be sent through:
79
- * HTTP: api.sendgrid.com
80
- * EU region means the message should be sent through:
81
- * HTTP: api.eu.sendgrid.com
82
- */
83
- // @return [Request] the modified request object
84
- func SetHost (request rest.Request , host string ) (rest.Request , error ) {
85
- endpoint , err := extractEndpoint (request .BaseURL )
86
- if err != nil {
87
- return request , err
88
- }
89
-
90
- request .BaseURL = host + endpoint
91
- return request , nil
92
- }
93
-
94
- // SetDataResidency modifies the host as per the region
95
- // @return [Request] the modified request object
96
- func SetDataResidency (request rest.Request , region string ) (rest.Request , error ) {
97
- regionalHost , present := allowedRegionsHostMap [region ]
98
- if ! present {
99
- return request , errors .New ("error: region can only be \" eu\" or \" global\" " )
100
- }
101
- request , err := SetHost (request , regionalHost )
102
- if err != nil {
103
- return request , err
104
- }
105
- return request , nil
106
- }
107
-
108
58
// Send sends an email through Twilio SendGrid
109
59
func (cl * Client ) Send (email * mail.SGMailV3 ) (* rest.Response , error ) {
110
60
return cl .SendWithContext (context .Background (), email )
0 commit comments