diff --git a/fastly/automation_token.go b/fastly/automation_token.go index a39d6f5b..6ef5d403 100644 --- a/fastly/automation_token.go +++ b/fastly/automation_token.go @@ -142,10 +142,11 @@ type CreateAutomationTokenInput struct { // // Requires sudo capability for the token being used. func (c *Client) CreateAutomationToken(i *CreateAutomationTokenInput) (*AutomationToken, error) { - _, err := c.PostForm("/sudo", i, nil) + ignored, err := c.PostForm("/sudo", i, nil) if err != nil { return nil, err } + defer ignored.Body.Close() resp, err := c.PostJSON("/automation-tokens", i, nil) if err != nil { diff --git a/fastly/domain.go b/fastly/domain.go index 3e1c59af..f4f117c9 100644 --- a/fastly/domain.go +++ b/fastly/domain.go @@ -189,8 +189,12 @@ func (c *Client) DeleteDomain(i *DeleteDomainInput) error { path := ToSafeURL("service", i.ServiceID, "version", strconv.Itoa(i.ServiceVersion), "domain", i.Name) - _, err := c.Delete(path, nil) - return err + ignored, err := c.Delete(path, nil) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } // ValidateDomainInput is used as input to the ValidateDomain function. diff --git a/fastly/kv_store.go b/fastly/kv_store.go index 465ed0a2..414e3d7e 100644 --- a/fastly/kv_store.go +++ b/fastly/kv_store.go @@ -463,8 +463,12 @@ func (c *Client) InsertKVStoreKey(i *InsertKVStoreKeyInput) error { } defer resp.Body.Close() - _, err = checkResp(resp, err) - return err + ignored, err := checkResp(resp, err) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } // DeleteKVStoreKeyInput is the input to the DeleteKVStoreKey function. @@ -534,6 +538,10 @@ func (c *Client) BatchModifyKVStoreKey(i *BatchModifyKVStoreKeyInput) error { } defer resp.Body.Close() - _, err = checkResp(resp, err) - return err + ignored, err := checkResp(resp, err) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } diff --git a/fastly/managed_logging.go b/fastly/managed_logging.go index 3e0efe2a..f7275013 100644 --- a/fastly/managed_logging.go +++ b/fastly/managed_logging.go @@ -92,6 +92,10 @@ func (c *Client) DeleteManagedLogging(i *DeleteManagedLoggingInput) error { return ErrNotImplemented } - _, err := c.Delete(path, nil) - return err + ignored, err := c.Delete(path, nil) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } diff --git a/fastly/product_enablement.go b/fastly/product_enablement.go index 913b4863..f2fac193 100644 --- a/fastly/product_enablement.go +++ b/fastly/product_enablement.go @@ -127,6 +127,10 @@ func (c *Client) DisableProduct(i *ProductEnablementInput) error { path := ToSafeURL("enabled-products", i.ProductID.String(), "services", i.ServiceID) - _, err := c.Delete(path, nil) - return err + ignored, err := c.Delete(path, nil) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } diff --git a/fastly/service_authorization.go b/fastly/service_authorization.go index 5ccf4835..786f2bd0 100644 --- a/fastly/service_authorization.go +++ b/fastly/service_authorization.go @@ -219,7 +219,10 @@ func (c *Client) DeleteServiceAuthorization(i *DeleteServiceAuthorizationInput) path := ToSafeURL("service-authorizations", i.ID) - _, err := c.Delete(path, nil) - - return err + ignored, err := c.Delete(path, nil) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } diff --git a/fastly/tls_custom_activation.go b/fastly/tls_custom_activation.go index 4e8d9699..865307ae 100644 --- a/fastly/tls_custom_activation.go +++ b/fastly/tls_custom_activation.go @@ -221,6 +221,10 @@ func (c *Client) DeleteTLSActivation(i *DeleteTLSActivationInput) error { path := ToSafeURL("tls", "activations", i.ID) - _, err := c.Delete(path, nil) - return err + ignored, err := c.Delete(path, nil) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } diff --git a/fastly/tls_custom_certificate.go b/fastly/tls_custom_certificate.go index 67f8e05c..cbc235da 100644 --- a/fastly/tls_custom_certificate.go +++ b/fastly/tls_custom_certificate.go @@ -222,6 +222,10 @@ func (c *Client) DeleteCustomTLSCertificate(i *DeleteCustomTLSCertificateInput) path := ToSafeURL("tls", "certificates", i.ID) - _, err := c.Delete(path, nil) - return err + ignored, err := c.Delete(path, nil) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } diff --git a/fastly/tls_mutual_authentication.go b/fastly/tls_mutual_authentication.go index 08476794..043000e0 100644 --- a/fastly/tls_mutual_authentication.go +++ b/fastly/tls_mutual_authentication.go @@ -204,6 +204,10 @@ func (c *Client) DeleteTLSMutualAuthentication(i *DeleteTLSMutualAuthenticationI path := ToSafeURL("tls", "mutual_authentications", i.ID) - _, err := c.Delete(path, nil) - return err + ignored, err := c.Delete(path, nil) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } diff --git a/fastly/tls_platform.go b/fastly/tls_platform.go index e4af2ae2..d329ee2e 100644 --- a/fastly/tls_platform.go +++ b/fastly/tls_platform.go @@ -236,6 +236,10 @@ func (c *Client) DeleteBulkCertificate(i *DeleteBulkCertificateInput) error { path := ToSafeURL("tls", "bulk", "certificates", i.ID) - _, err := c.Delete(path, nil) - return err + ignored, err := c.Delete(path, nil) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } diff --git a/fastly/tls_private_keys.go b/fastly/tls_private_keys.go index ad9762e1..6117fe53 100644 --- a/fastly/tls_private_keys.go +++ b/fastly/tls_private_keys.go @@ -164,6 +164,10 @@ func (c *Client) DeletePrivateKey(i *DeletePrivateKeyInput) error { path := ToSafeURL("tls", "private_keys", i.ID) - _, err := c.Delete(path, nil) - return err + ignored, err := c.Delete(path, nil) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } diff --git a/fastly/tls_subscription.go b/fastly/tls_subscription.go index 0e8f358a..721869e4 100644 --- a/fastly/tls_subscription.go +++ b/fastly/tls_subscription.go @@ -319,6 +319,10 @@ func (c *Client) DeleteTLSSubscription(i *DeleteTLSSubscriptionInput) error { path := ToSafeURL("tls", "subscriptions", i.ID) - _, err := c.Delete(path, &ro) - return err + ignored, err := c.Delete(path, &ro) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } diff --git a/fastly/token.go b/fastly/token.go index 2f87ca24..b35f93ba 100644 --- a/fastly/token.go +++ b/fastly/token.go @@ -118,10 +118,11 @@ type CreateTokenInput struct { // CreateToken creates a new resource. func (c *Client) CreateToken(i *CreateTokenInput) (*Token, error) { - _, err := c.PostForm("/sudo", i, nil) + ignored, err := c.PostForm("/sudo", i, nil) if err != nil { return nil, err } + defer ignored.Body.Close() resp, err := c.PostForm("/tokens", i, nil) if err != nil { @@ -194,6 +195,10 @@ func (c *Client) BatchDeleteTokens(i *BatchDeleteTokensInput) error { if len(i.Tokens) == 0 { return ErrMissingTokensValue } - _, err := c.DeleteJSONAPIBulk("/tokens", i.Tokens, nil) - return err + ignored, err := c.DeleteJSONAPIBulk("/tokens", i.Tokens, nil) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } diff --git a/fastly/waf.go b/fastly/waf.go index 1b396b93..8b98c835 100644 --- a/fastly/waf.go +++ b/fastly/waf.go @@ -273,8 +273,12 @@ func (c *Client) DeleteWAF(i *DeleteWAFInput) error { path := ToSafeURL("waf", "firewalls", i.ID) - _, err := c.DeleteJSONAPI(path, i, nil) - return err + ignored, err := c.DeleteJSONAPI(path, i, nil) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } // infoResponse is used to pull the links and meta from the result. diff --git a/fastly/waf_active_rule.go b/fastly/waf_active_rule.go index a31d62a4..96e1ba40 100644 --- a/fastly/waf_active_rule.go +++ b/fastly/waf_active_rule.go @@ -298,6 +298,10 @@ func (c *Client) DeleteWAFActiveRules(i *DeleteWAFActiveRulesInput) error { path := ToSafeURL("waf", "firewalls", i.WAFID, "versions", strconv.Itoa(i.WAFVersionNumber), "active-rules") - _, err := c.DeleteJSONAPIBulk(path, i.Rules, nil) - return err + ignored, err := c.DeleteJSONAPIBulk(path, i.Rules, nil) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } diff --git a/fastly/waf_rule_exclusion.go b/fastly/waf_rule_exclusion.go index 231509ca..b4c72fdb 100644 --- a/fastly/waf_rule_exclusion.go +++ b/fastly/waf_rule_exclusion.go @@ -304,6 +304,10 @@ func (c *Client) DeleteWAFRuleExclusion(i *DeleteWAFRuleExclusionInput) error { path := ToSafeURL("waf", "firewalls", i.WAFID, "versions", strconv.Itoa(i.WAFVersionNumber), "exclusions", strconv.Itoa(i.Number)) - _, err := c.Delete(path, nil) - return err + ignored, err := c.Delete(path, nil) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } diff --git a/fastly/waf_version.go b/fastly/waf_version.go index 29ed0a72..8f17d40e 100644 --- a/fastly/waf_version.go +++ b/fastly/waf_version.go @@ -437,8 +437,12 @@ func (c *Client) DeployWAFVersion(i *DeployWAFVersionInput) error { path := ToSafeURL("waf", "firewalls", i.WAFID, "versions", strconv.Itoa(i.WAFVersionNumber), "activate") - _, err := c.PutJSONAPI(path, &DeployWAFVersionInput{}, nil) - return err + ignored, err := c.PutJSONAPI(path, &DeployWAFVersionInput{}, nil) + if err != nil { + return err + } + defer ignored.Body.Close() + return nil } // CreateEmptyWAFVersionInput creates a new resource.