Samuel A. Falvo II | fd78c30 | 2013-06-25 16:35:32 -0700 | [diff] [blame] | 1 | package gophercloud |
| 2 | |
Samuel A. Falvo II | 5d0d74c | 2013-06-25 17:23:18 -0700 | [diff] [blame^] | 3 | import ( |
| 4 | "net/http" |
| 5 | ) |
| 6 | |
Samuel A. Falvo II | fd78c30 | 2013-06-25 16:35:32 -0700 | [diff] [blame] | 7 | type Context struct { |
Samuel A. Falvo II | 5d0d74c | 2013-06-25 17:23:18 -0700 | [diff] [blame^] | 8 | // providerMap serves as a directory of supported providers. |
Samuel A. Falvo II | fd78c30 | 2013-06-25 16:35:32 -0700 | [diff] [blame] | 9 | providerMap map[string]*Provider |
Samuel A. Falvo II | 5d0d74c | 2013-06-25 17:23:18 -0700 | [diff] [blame^] | 10 | |
| 11 | // httpClient refers to the current HTTP client interface to use. |
| 12 | httpClient *http.Client |
Samuel A. Falvo II | fd78c30 | 2013-06-25 16:35:32 -0700 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | func TestContext() *Context { |
| 16 | return &Context{ |
| 17 | providerMap: make(map[string]*Provider), |
Samuel A. Falvo II | 5d0d74c | 2013-06-25 17:23:18 -0700 | [diff] [blame^] | 18 | httpClient: &http.Client{}, |
Samuel A. Falvo II | fd78c30 | 2013-06-25 16:35:32 -0700 | [diff] [blame] | 19 | } |
| 20 | } |
Samuel A. Falvo II | 5d0d74c | 2013-06-25 17:23:18 -0700 | [diff] [blame^] | 21 | |
| 22 | func (c *Context) UseCustomClient(hc *http.Client) { |
| 23 | c.httpClient = hc; |
| 24 | } |