Skip to content

Commit

Permalink
http: Add api.DefaultTransport in http.Client (#59)
Browse files Browse the repository at this point in the history
Adds the defined sdk `api.DefaultTransport` to the default `http.Client`
used by all the API requests. It fixes the issue where responses with a
StatusCode different to those specified in the swagger spec result in
either an `unknown response` or blank response which makes for very bad
UX. After this change, the body of those requests will be shown to the
user.

Signed-off-by: Marc Lopez <marc5.12@outlook.com>
  • Loading branch information
marclop committed Nov 25, 2019
1 parent 21176cd commit 72fc278
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ github.com/asaskevich/govalidator MIT
github.com/blang/semver MIT
github.com/chzyer/test MIT
github.com/spf13/viper MIT
github.com/hashicorp/go-multierror MPL-2.0-no-copyleft-exception
github.com/hashicorp/go-multierror MPL-2.0
github.com/chzyer/logex no license file was found
github.com/ghodss/yaml no license file was found

Expand Down
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"path/filepath"
"time"

"github.com/elastic/cloud-sdk-go/pkg/api"
"github.com/elastic/cloud-sdk-go/pkg/output"
multierror "github.com/hashicorp/go-multierror"
"github.com/spf13/cobra"
Expand All @@ -44,7 +45,7 @@ const (
)

var (
defaultClient = new(http.Client)
defaultClient = &http.Client{Transport: api.DefaultTransport}
defaultOutput = os.Stdout
defaultInput = os.Stdin
defaultError = os.Stderr
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/chzyer/logex v1.1.10 // indirect
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect
github.com/davecgh/go-spew v1.1.1
github.com/elastic/cloud-sdk-go v1.0.0-bc5
github.com/elastic/cloud-sdk-go v1.0.0-bc6
github.com/elastic/uptd v1.0.0
github.com/ghodss/yaml v1.0.0
github.com/go-openapi/runtime v0.19.8
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/elastic/cloud-sdk-go v1.0.0-bc5 h1:POlV6bafKwT728xJy+did8Q1QlDweE0z/lVfgRY6ic4=
github.com/elastic/cloud-sdk-go v1.0.0-bc5/go.mod h1:19tuRaJglGTECDJfiWEDMOVj23ZL+9+YYoIV1fZIGzc=
github.com/elastic/cloud-sdk-go v1.0.0-bc6 h1:vxt738VM/thyF2QD3mBFNRR1n2Hv0qFJetOXQv/9NbQ=
github.com/elastic/cloud-sdk-go v1.0.0-bc6/go.mod h1:19tuRaJglGTECDJfiWEDMOVj23ZL+9+YYoIV1fZIGzc=
github.com/elastic/uptd v1.0.0 h1:oUhbbTK6hjFYB5w5dwjo1HtbqrWyLiqj+6Sb05oawU8=
github.com/elastic/uptd v1.0.0/go.mod h1:2Pm07gLal/a/gTPq3el2QgOjoxu97pB2I17AprXxa48=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
Expand Down

0 comments on commit 72fc278

Please sign in to comment.