mirror of
https://github.com/gofiber/fiber.git
synced 2025-05-03 06:10:17 +00:00
* 🐛 bug: fix EnableSplittingOnParsers is not functional
* remove wrong testcase
* add support for external xml decoders
* improve test coverage
* fix linter
* update
* add reset methods
* improve test coverage
* merge Form and MultipartForm methods
* fix linter
* split reset and putting steps
* fix linter
26 lines
518 B
Go
26 lines
518 B
Go
package binder
|
|
|
|
import (
|
|
"github.com/gofiber/utils/v2"
|
|
)
|
|
|
|
// JSONBinding is the JSON binder for JSON request body.
|
|
type JSONBinding struct {
|
|
JSONDecoder utils.JSONUnmarshal
|
|
}
|
|
|
|
// Name returns the binding name.
|
|
func (*JSONBinding) Name() string {
|
|
return "json"
|
|
}
|
|
|
|
// Bind parses the request body as JSON and returns the result.
|
|
func (b *JSONBinding) Bind(body []byte, out any) error {
|
|
return b.JSONDecoder(body, out)
|
|
}
|
|
|
|
// Reset resets the JSONBinding binder.
|
|
func (b *JSONBinding) Reset() {
|
|
b.JSONDecoder = nil
|
|
}
|