Skip to content

Commit

Permalink
chore: set edge, region
Browse files Browse the repository at this point in the history
  • Loading branch information
tiwarishubham635 committed Sep 26, 2024
1 parent 7ab686d commit a2e91a7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions sendgrid.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ var allowedRegionsHostMap = map[string]string{
"global": "https://api.sendgrid.com",
}

// map for allowed regions, global and eu currently
var allowedRegions = map[string]bool{
"eu": true,
"global": true,
}

// GetRequest
// @return [Request] a default request object
func GetRequest(key, endpoint, host string) rest.Request {
Expand Down Expand Up @@ -124,6 +130,28 @@ func extractEndpoint(link string) (string, error) {
return parsedURL.Path, nil
}

// SetTimeout sets the Timeout for Twilio HTTP requests.
func (c *RestClient) SetTimeout(timeout time.Duration) {
c.RequestHandler.Client.SetTimeout(timeout)
}

// SetEdge sets the Edge for the Twilio request.
// Not supported in sendgrid currently
func (c *RestClient) SetEdge(edge string) {
c.RequestHandler.Edge = edge
}

// SetRegion sets the Region for the Twilio request. Defaults to "us1" if an edge is provided.
func (c *RestClient) SetRegion(region string) {
// check if region in "eu" or "global"

//isAllowed, presentInMap := allowedRegions[region]
//if !presentInMap || !isAllowed {
// return errors.New("error: region can only be \"eu\" or \"global\"")
//}
c.RequestHandler.Region = region
}

// SetDataResidency modifies the host as per the region
/*
* This allows support for global and eu regions only. This set will likely expand in the future.
Expand Down

0 comments on commit a2e91a7

Please sign in to comment.