Commit 5ec4b8f
committed
feat: add WithBodyDecoder option for custom JSON body decoding
Add a BodyDecoderFunc type and WithBodyDecoder router option that lets
consumers customize how JSON request bodies are decoded. The default
remains runtime.DecodeJSONBody, so this is fully backward-compatible.
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 context
The option follows the same pattern as WithErrorHandler and is
supported across all router backends.1 parent f62fd5e commit 5ec4b8f
52 files changed
Lines changed: 848 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
- beego
- chi
- echo
- fasthttp
- fiber
- gin
- go-zero
- goframe
- gorilla-mux
- hertz
- iris
- kratos
- std-http
- runtime
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
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: 17 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments