Skip to content

Commit

Permalink
fix(pdk): types related to message body should be bytes (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlightIbuki authored Dec 7, 2022
1 parent 287b737 commit 4deec45
Show file tree
Hide file tree
Showing 6 changed files with 899 additions and 757 deletions.
72 changes: 72 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,77 @@
# Table of Contents

- [v0.9.0](#v050)
- [v0.8.0](#v040)
- [v0.7.1](#v031)
- [v0.6.0](#v060)
- [v0.5.0](#v050)
- [v0.4.0](#v040)
- [v0.3.1](#v031)

## [v0.9.0]

> Released 2022/12/07
### Changes

- Fixed parameter type of `kong.service.request.set_raw_body`, return type of
`kong.service.response.get_raw_body`,
and body parameter type of `kong.response.exit` to `[]byte`.
Note that old version (before 3.0.1, or commits before cd2bcf9) of kong is incompatible after this change.
[#132](https://github.com/Kong/go-pdk/pull/132)
[kong/kong#9526](https://github.com/Kong/kong/pull/9526)

## [v0.8.0]

> Released 2021/06/09
### Changes

- fix kong.Request.GetRawBody() with buffered content by @javierguerragiraldez in [#91](https://github.com/Kong/go-pdk/pull/91)
- avoid pass-by-value of objects that contain locks. by @javierguerragiraldez in [#79](https://github.com/Kong/go-pdk/pull/79)
- bump go version by @fffonion in [#112](https://github.com/Kong/go-pdk/pull/112)

### Addtions

- chore(*) add dependabot by @mayocream in [#98](https://github.com/Kong/go-pdk/pull/98)

## [v0.7.1]

> Released 2021/10/16
### Changes

- fix testing: don't break when the plugin Exit()s [#73](https://github.com/Kong/go-pdk/pull/73)
- Ignore unexported struct fields in config struct by @ctrox [#69](https://github.com/Kong/go-pdk/pull/69)
- Start every Headers field empty but non-null [#74](https://github.com/Kong/go-pdk/pull/74)

### Additions

- Feat/plugin testing [#64](https://github.com/Kong/go-pdk/pull/64)
- Add godoc comments [#65](https://github.com/Kong/go-pdk/pull/65)

## [v0.7.0]

> Released 2021/10/16
New ProtoBuf-based communications with Kong. Requires Kong 2.4.

## [v0.6.1]

> Released 2021/04/14
### Changes

- API bugfix: port values were given as string instead of Int

## [v0.6.0]

> Released 2021/04/14
### Additions

- New Embedded Server to replace the go-pluginserver. Requires Kong v2.3.

## [v0.5.0]

> Released 2020/05/27
Expand Down Expand Up @@ -52,6 +120,10 @@

[Back to TOC](#table-of-contents)

[v0.9.0]: https://github.com/Kong/kong/compare/v0.8.0..v0.9.0
[v0.8.0]: https://github.com/Kong/kong/compare/v0.7.0..v0.8.0
[v0.7.0]: https://github.com/Kong/kong/compare/v0.6.1..v0.7.0
[v0.6.0]: https://github.com/Kong/kong/compare/v0.5.0..v0.6.0
[v0.5.0]: https://github.com/Kong/kong/compare/v0.4.0..v0.5.0
[v0.4.0]: https://github.com/Kong/kong/compare/v0.3.1..v0.4.0
[v0.3.1]: https://github.com/Kong/kong/compare/v0.3.0..v0.3.1
Expand Down
4 changes: 4 additions & 0 deletions bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ func WrapString(s string) *kong_plugin_protocol.String {
return &kong_plugin_protocol.String{V: s}
}

func WrapByteString(s []byte) *kong_plugin_protocol.ByteString {
return &kong_plugin_protocol.ByteString{V: s}
}

func WrapHeaders(h map[string][]string) (*structpb.Struct, error) {
h2 := make(map[string]interface{}, len(h))
for k, v := range h {
Expand Down
2 changes: 1 addition & 1 deletion response/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (r Response) SetHeaders(headers map[string][]string) error {
// Unless manually specified, this method will automatically set the
// Content-Length header in the produced response for convenience.

func (r Response) Exit(status int, body string, headers map[string][]string) {
func (r Response) Exit(status int, body []byte, headers map[string][]string) {
h, _ := bridge.WrapHeaders(headers)
arg := kong_plugin_protocol.ExitArgs{
Status: int32(status),
Expand Down
Loading

0 comments on commit 4deec45

Please sign in to comment.