Skip to content

Commit

Permalink
feat: add flat error support to config update
Browse files Browse the repository at this point in the history
  • Loading branch information
rainest committed Feb 3, 2023
1 parent ab5b18a commit 1cbdb01
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
`ConfigService`, now part of `kong.Client`) now has the response signature
`([]byte, error)` instead of `error`. The byte slice is the config response
body. The error is unchanged.
- **Breaking change:** `ReloadDeclarativeRawConfig()` now requires a
`flattenErrors` boolean argument. When `true`, requests will include
`flatten_errors=1` in the query string, to activate the functionality added
in https://github.com/Kong/kong/pull/10161.
[#273](https://github.com/Kong/go-kong/pull/273)

## [v0.36.0]
Expand Down
15 changes: 13 additions & 2 deletions kong/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,26 @@ func (c *Client) ReloadDeclarativeRawConfig(
ctx context.Context,
config io.Reader,
checkHash bool,
flattenErrors bool,
) ([]byte, error) {
type sendConfigParams struct {
CheckHash int `url:"check_hash"`
CheckHash int `url:"check_hash"`
FlattenErrors int `url:"flatten_errors"`
}
var checkHashI int
if checkHash {
checkHashI = 1
}
req, err := c.NewRequest("POST", "/config", sendConfigParams{CheckHash: checkHashI}, config)
var flattenErrorsI int
if flattenErrors {
flattenErrorsI = 1
}
req, err := c.NewRequest(
"POST",
"/config",
sendConfigParams{CheckHash: checkHashI, FlattenErrors: flattenErrorsI},
config,
)
if err != nil {
return nil, fmt.Errorf("creating new HTTP request for /config: %w", err)
}
Expand Down

0 comments on commit 1cbdb01

Please sign in to comment.