|
|
@@ -24,6 +24,8 @@ type Client struct {
|
|
|
Cookie *http.Cookie
|
|
|
CookieFilePath string
|
|
|
Token string
|
|
|
+
|
|
|
+ cfToken string
|
|
|
}
|
|
|
|
|
|
// NewClient constructs a new client based on a set of options
|
|
|
@@ -45,6 +47,11 @@ func NewClient(baseURL string, cookieFileName string) *Client {
|
|
|
client.Cookie = cookie
|
|
|
}
|
|
|
|
|
|
+ // look for a cloudflare access token specifically for Porter
|
|
|
+ if cfToken := os.Getenv("PORTER_CF_ACCESS_TOKEN"); cfToken != "" {
|
|
|
+ client.cfToken = cfToken
|
|
|
+ }
|
|
|
+
|
|
|
return client
|
|
|
}
|
|
|
|
|
|
@@ -57,6 +64,11 @@ func NewClientWithToken(baseURL, token string) *Client {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
+ // look for a cloudflare access token specifically for Porter
|
|
|
+ if cfToken := os.Getenv("PORTER_CF_ACCESS_TOKEN"); cfToken != "" {
|
|
|
+ client.cfToken = cfToken
|
|
|
+ }
|
|
|
+
|
|
|
return client
|
|
|
}
|
|
|
|
|
|
@@ -191,6 +203,10 @@ func (c *Client) sendRequest(req *http.Request, v interface{}, useCookie bool) (
|
|
|
req.AddCookie(c.Cookie)
|
|
|
}
|
|
|
|
|
|
+ if c.cfToken != "" {
|
|
|
+ req.Header.Set("cf-access-token", c.cfToken)
|
|
|
+ }
|
|
|
+
|
|
|
res, err := c.HTTPClient.Do(req)
|
|
|
|
|
|
if err != nil {
|