Skip to content

Commit

Permalink
feat: Disable gzipped request payloads by default
Browse files Browse the repository at this point in the history
  • Loading branch information
kfcampbell authored Jul 26, 2024
1 parent 73e17cf commit 7f6cddb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
16 changes: 12 additions & 4 deletions stage/go/go-sdk-enterprise-cloud/pkg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import (
// Client (wrapper of *github.ApiClient) with the provided option functions.
// By default, it includes a rate limiting middleware.
func NewApiClient(optionFuncs ...ClientOptionFunc) (*Client, error) {
options := GetDefaultClientOptions()
options, err := GetDefaultClientOptions()
if err != nil {
return nil, fmt.Errorf("failed to get default client options: %v", err)
}
for _, optionFunc := range optionFuncs {
optionFunc(options)
}
Expand Down Expand Up @@ -118,12 +121,17 @@ type ClientOptions struct {

// GetDefaultClientOptions returns a new instance of ClientOptions with default values.
// This is used in the NewApiClient constructor before applying user-defined custom options.
func GetDefaultClientOptions() *ClientOptions {
func GetDefaultClientOptions() (*ClientOptions, error) {
turnOffCompression := kiotaHttp.NewCompressionOptions(false)
middlewares, err := kiotaHttp.GetDefaultMiddlewaresWithOptions(&turnOffCompression)
if err != nil {
return nil, fmt.Errorf("failed to get middleware with compression turned off: %v", err)
}
return &ClientOptions{
UserAgent: "octokit/go-sdk",
APIVersion: "2022-11-28",
Middleware: kiotaHttp.GetDefaultMiddlewares(),
}
Middleware: middlewares,
}, nil
}

// ClientOptionFunc provides a functional pattern for client configuration
Expand Down
16 changes: 12 additions & 4 deletions stage/go/go-sdk-enterprise-server/pkg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import (
// Client (wrapper of *github.ApiClient) with the provided option functions.
// By default, it includes a rate limiting middleware.
func NewApiClient(optionFuncs ...ClientOptionFunc) (*Client, error) {
options := GetDefaultClientOptions()
options, err := GetDefaultClientOptions()
if err != nil {
return nil, fmt.Errorf("failed to get default client options: %v", err)
}
for _, optionFunc := range optionFuncs {
optionFunc(options)
}
Expand Down Expand Up @@ -118,12 +121,17 @@ type ClientOptions struct {

// GetDefaultClientOptions returns a new instance of ClientOptions with default values.
// This is used in the NewApiClient constructor before applying user-defined custom options.
func GetDefaultClientOptions() *ClientOptions {
func GetDefaultClientOptions() (*ClientOptions, error) {
turnOffCompression := kiotaHttp.NewCompressionOptions(false)
middlewares, err := kiotaHttp.GetDefaultMiddlewaresWithOptions(&turnOffCompression)
if err != nil {
return nil, fmt.Errorf("failed to get middleware with compression turned off: %v", err)
}
return &ClientOptions{
UserAgent: "octokit/go-sdk",
APIVersion: "2022-11-28",
Middleware: kiotaHttp.GetDefaultMiddlewares(),
}
Middleware: middlewares,
}, nil
}

// ClientOptionFunc provides a functional pattern for client configuration
Expand Down
16 changes: 12 additions & 4 deletions stage/go/go-sdk/pkg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import (
// Client (wrapper of *github.ApiClient) with the provided option functions.
// By default, it includes a rate limiting middleware.
func NewApiClient(optionFuncs ...ClientOptionFunc) (*Client, error) {
options := GetDefaultClientOptions()
options, err := GetDefaultClientOptions()
if err != nil {
return nil, fmt.Errorf("failed to get default client options: %v", err)
}
for _, optionFunc := range optionFuncs {
optionFunc(options)
}
Expand Down Expand Up @@ -118,12 +121,17 @@ type ClientOptions struct {

// GetDefaultClientOptions returns a new instance of ClientOptions with default values.
// This is used in the NewApiClient constructor before applying user-defined custom options.
func GetDefaultClientOptions() *ClientOptions {
func GetDefaultClientOptions() (*ClientOptions, error) {
turnOffCompression := kiotaHttp.NewCompressionOptions(false)
middlewares, err := kiotaHttp.GetDefaultMiddlewaresWithOptions(&turnOffCompression)
if err != nil {
return nil, fmt.Errorf("failed to get middleware with compression turned off: %v", err)
}
return &ClientOptions{
UserAgent: "octokit/go-sdk",
APIVersion: "2022-11-28",
Middleware: kiotaHttp.GetDefaultMiddlewares(),
}
Middleware: middlewares,
}, nil
}

// ClientOptionFunc provides a functional pattern for client configuration
Expand Down

0 comments on commit 7f6cddb

Please sign in to comment.