Commit 48fe92a9 by Victor Cinaglia

snapshots: Close response body after error check

parent 411d67ca
...@@ -51,13 +51,10 @@ func createExternalDashboardSnapshot(cmd m.CreateDashboardSnapshotCommand) (*Cre ...@@ -51,13 +51,10 @@ func createExternalDashboardSnapshot(cmd m.CreateDashboardSnapshotCommand) (*Cre
} }
response, err := client.Post(setting.ExternalSnapshotUrl+"/api/snapshots", "application/json", bytes.NewBuffer(messageBytes)) response, err := client.Post(setting.ExternalSnapshotUrl+"/api/snapshots", "application/json", bytes.NewBuffer(messageBytes))
if response != nil {
defer response.Body.Close()
}
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer response.Body.Close()
if response.StatusCode != 200 { if response.StatusCode != 200 {
return nil, fmt.Errorf("Create external snapshot response status code %d", response.StatusCode) return nil, fmt.Errorf("Create external snapshot response status code %d", response.StatusCode)
...@@ -159,14 +156,10 @@ func GetDashboardSnapshot(c *m.ReqContext) { ...@@ -159,14 +156,10 @@ func GetDashboardSnapshot(c *m.ReqContext) {
func deleteExternalDashboardSnapshot(externalUrl string) error { func deleteExternalDashboardSnapshot(externalUrl string) error {
response, err := client.Get(externalUrl) response, err := client.Get(externalUrl)
if response != nil {
defer response.Body.Close()
}
if err != nil { if err != nil {
return err return err
} }
defer response.Body.Close()
if response.StatusCode == 200 { if response.StatusCode == 200 {
return nil return nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment