Skip to content

Commit

Permalink
close all bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
dzyanis committed Mar 16, 2022
1 parent 70964ec commit dd09c5f
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions provider/freemobile/freemobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func (c *FreeMobile) Send(message sachet.Message) error {
if err != nil {
return err
}
defer response.Body.Close()

if response.StatusCode == http.StatusOK && err == nil {
return nil
Expand Down
1 change: 1 addition & 0 deletions provider/kannel/kannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (c *Kannel) Send(message sachet.Message) error {
if err != nil {
return err
}
defer response.Body.Close()

if response.StatusCode >= http.StatusBadRequest {
return fmt.Errorf("Failed sending sms. statusCode: %d", response.StatusCode)
Expand Down
1 change: 1 addition & 0 deletions provider/sap/sap.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (c *Sap) Send(message sachet.Message) error {
if err != nil {
return err
}
defer response.Body.Close()

if response.StatusCode == http.StatusOK && err == nil {
return nil
Expand Down
1 change: 1 addition & 0 deletions provider/sipgate/sipgate.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (c *Sipgate) Send(message sachet.Message) error {
if err != nil {
return err
}
defer response.Body.Close()

if response.StatusCode != http.StatusNoContent {
return fmt.Errorf("Failed sending sms. statusCode: %d", response.StatusCode)
Expand Down
2 changes: 2 additions & 0 deletions provider/sms77/sms77.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type Config struct {
Debug bool `yaml:"debug"`
}

var _ (sachet.Provider) = (*Sms77)(nil)

// Sms77 contains the necessary values for the Sms77 provider.
type Sms77 struct {
client *sms77api.Sms77API
Expand Down
2 changes: 2 additions & 0 deletions provider/smsc/smsc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type Config struct {

const SmscRequestTimeout = time.Second * 60

var _ (sachet.Provider) = (*Smsc)(nil)

type Smsc struct {
Login string
Password string
Expand Down
2 changes: 2 additions & 0 deletions provider/telegram/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type Config struct {
DisableWebPagePreview bool `yaml:"disable_web_page_preview"`
}

var _ (sachet.Provider) = (*Telegram)(nil)

type Telegram struct {
bot *tgbotapi.BotAPI
config *Config
Expand Down
2 changes: 2 additions & 0 deletions provider/textmagic/textmagic.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type Config struct {
APIKey string `yaml:"api_key"`
}

var _ (sachet.Provider) = (*TextMagic)(nil)

type TextMagic struct {
client *textmagic.APIClient
auth context.Context
Expand Down
3 changes: 3 additions & 0 deletions provider/turbosms/turbosms.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type Config struct {
Apassword string `yaml:"password"`
}

var _ (sachet.Provider) = (*Turbosms)(nil)

type Turbosms struct {
Login string
Password string
Expand Down Expand Up @@ -99,6 +101,7 @@ func Request(c *http.Client, url string, payload []byte) ([]byte, error, int) {
if err != nil {
return nil, err, statuscode
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
Expand Down

0 comments on commit dd09c5f

Please sign in to comment.