fiber/binder/json.go
RW fe1bf4a0b3
feat(ctx): add conditional copy helpers (#3703)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-08-26 07:54:15 +02:00

26 lines
524 B
Go

package binder
import (
utils "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
}