Ash Wilson | 70dfe0c | 2014-08-28 13:57:09 -0400 | [diff] [blame] | 1 | package gophercloud |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | ) |
| 6 | |
| 7 | // ServiceClient stores details about a specific service that are necessary for further interactions |
| 8 | // with that service API, as well as utility methods for service implementation. |
| 9 | // |
| 10 | // Generally, you will acquire a ServiceClient by calling the NewClient() function in the |
| 11 | // appropriate service package. |
| 12 | type ServiceClient struct { |
| 13 | authority AuthResults |
| 14 | options AuthOptions |
| 15 | endpoint string |
| 16 | tokenID string |
| 17 | } |
| 18 | |
| 19 | // ServiceURL constructs a URL for a resource belonging to this client. |
| 20 | func (client *ServiceClient) ServiceURL(parts ...string) string { |
| 21 | return client.endpoint + strings.Join(parts, "/") |
| 22 | } |
| 23 | |
| 24 | // AuthenticatedHeaders returns a map of HTTP headers that are common for all authenticated service |
| 25 | // requests. |
| 26 | func (client *ServiceClient) AuthenticatedHeaders() map[string]string { |
| 27 | return map[string]string{"X-Auth-Token": client.tokenID} |
| 28 | } |