Commit 37cf95b
committed
feat: add SetBodyDecoder for custom JSON body decoding
Add a BodyDecoderFunc type and SetBodyDecoder method on HTTPAdapter
that lets consumers customize how JSON request bodies are decoded.
The default remains runtime.DecodeJSONBody.
Source changes are limited to two files:
- pkg/runtime/json.go — BodyDecoderFunc type
- pkg/codegen/templates/handler/adapter.tmpl — field, default, setter
Use cases:
- Pre-process request bodies before decoding (e.g. strip nulls)
- Use a lenient decoder that tolerates schema mismatches
- Enrich decode errors with application-specific context1 parent f62fd5e commit 37cf95b
36 files changed
Lines changed: 493 additions & 159 deletions
File tree
- examples/server
- beego/api
- chi/api
- config-variations
- custom-service-name
- diff-package-multiple-files/models
- diff-package-single-file/models
- no-service
- same-package-multiple-files/api
- same-package-single-file
- zero-endpoints/api
- echo/api
- fasthttp/api
- fiber/api
- gin/api
- go-zero/api
- goframe/api
- gorilla-mux/api
- hertz/api
- iris/api
- kratos/api
- std-http/api
- test
- beego/testcase
- chi/testcase
- echo/testcase
- fasthttp/testcase
- fiber/testcase
- gin/testcase
- go-zero/testcase
- goframe/testcase
- gorilla-mux/testcase
- hertz/testcase
- iris/testcase
- kratos/testcase
- std-http/testcase
- pkg
- codegen/templates/handler
- runtime
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments