From 9924a41f7933deae15bb589d499f75d9304d8b93 Mon Sep 17 00:00:00 2001 From: Glenn McElhoe Date: Fri, 5 Nov 2021 16:29:28 -0400 Subject: [PATCH 1/2] Fix encryption field The field was misspelled. --- golang/uptime/checks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/golang/uptime/checks.go b/golang/uptime/checks.go index 877e8be..cafc032 100644 --- a/golang/uptime/checks.go +++ b/golang/uptime/checks.go @@ -49,7 +49,7 @@ type Check struct { DNSRecordType string `json:"msp_dns_record_type,omitempty"` // For IMAP, POP checks - Encryption string `json:"msp_encrytion,omitempty"` + Encryption string `json:"msp_encryption,omitempty"` // For Transaction checks Script string `json:"msp_script,omitempty"` From 76ff86f9d8444f2a05c70f57981101d235458c7d Mon Sep 17 00:00:00 2001 From: Glenn McElhoe Date: Fri, 5 Nov 2021 16:25:47 -0400 Subject: [PATCH 2/2] Add subaccount support Add a subsccount option to the Config. If present, it will add the subsccount header to the uptime.com REST calls. Signed-off-by: Glenn McElhoe --- golang/uptime/uptime.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/golang/uptime/uptime.go b/golang/uptime/uptime.go index 7f751ea..aca2a3e 100644 --- a/golang/uptime/uptime.go +++ b/golang/uptime/uptime.go @@ -23,17 +23,18 @@ const ( // Config represents the configuration for an Client.com client type Config struct { - BaseURL string - HTTPClient *http.Client - Token string - UserAgent string + BaseURL string + HTTPClient *http.Client + Token string + UserAgent string RateMilliseconds int + Subaccount string } // Client manages communication with the Uptime.com API. type Client struct { - client *http.Client // HTTP client used to communicate with the API. - common service + client *http.Client // HTTP client used to communicate with the API. + common service limiter <-chan time.Time // Base URL for API requests. BaseURL should always be specified @@ -151,6 +152,9 @@ func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Requ if c.Config.UserAgent != "" { req.Header.Add("User-Agent", c.Config.UserAgent) } + if c.Config.Subaccount != "" { + req.Header.Add("X-Subaccount", c.Config.Subaccount) + } return req, nil } @@ -161,7 +165,7 @@ func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*htt req = req.WithContext(ctx) // Observe rate limit - <- c.limiter + <-c.limiter resp, err := c.client.Do(req) if err != nil {