| 1 |
package fastly |
| 2 |
|
| 3 |
import "net/http" |
| 4 |
|
| 5 |
|
| 6 |
type EdgeCheck struct { |
| 7 |
Hash string `mapstructure:"hash"` |
| 8 |
Server string `mapstructure:"server"` |
| 9 |
ResponseTime float64 `mapstructure:"response_time"` |
| 10 |
Request *EdgeCheckRequest `mapstructure:"request"` |
| 11 |
Response *EdgeCheckResponse `mapstructure:"response"` |
| 12 |
} |
| 13 |
|
| 14 |
|
| 15 |
type EdgeCheckRequest struct { |
| 16 |
URL string `mapstructure:"url"` |
| 17 |
Method string `mapstructure:"method"` |
| 18 |
Headers *http.Header `mapstructure:"headers"` |
| 19 |
} |
| 20 |
|
| 21 |
|
| 22 |
type EdgeCheckResponse struct { |
| 23 |
Status uint `mapstructure:"status"` |
| 24 |
Headers *http.Header `mapstructure:"headers"` |
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
type EdgeCheckInput struct { |
| 29 |
URL string `form:"url,omitempty"` |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
func (c *Client) EdgeCheck(i *EdgeCheckInput) ([]*EdgeCheck, error) { |
| 35 |
resp, err := c.Get("/content/edge_check", &RequestOptions{ |
| 36 |
Params: map[string]string{ |
| 37 |
"url": i.URL, |
| 38 |
}, |
| 39 |
}) |
| 40 |
if err != nil { |
| 41 |
return nil, err |
| 42 |
} |
| 43 |
|
| 44 |
var e []*EdgeCheck |
| 45 |
if err := decodeJSON(&e, resp.Body); err != nil { |
| 46 |
return nil, err |
| 47 |
} |
| 48 |
return e, nil |
| 49 |
} |