· 4 years ago · Apr 16, 2021, 02:54 PM
1// Add headers for authenticating the client
2func addAuthHeaders(request *http.Request, c *Cloudflare) {
3
4 if c.Token != "" {
5 // Use the token if set
6 addBearer(request, c.Token)
7 } else if c.UserServiceKey != "" {
8 // Use UserService key if set
9 addUserServiceKey(request, c.UserServiceKey)
10 } else if c.Email != "" && c.ApiKey != "" {
11 // Use email and the api key if set
12 addApiKey(request, c.ApiKey, c.Email)
13 }
14
15 // Add the content type in any case
16 addContentType(request)
17}
18