mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 13:22:09 +08:00
fix: remove BindingBody change
This commit is contained in:
parent
d6c1821fc8
commit
e13d4afc42
@ -32,9 +32,9 @@ type Binding interface {
|
|||||||
Bind(*http.Request, any) error
|
Bind(*http.Request, any) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Body adds BindBody method to Binding. BindBody is similar with Bind,
|
// BindingBody adds BindBody method to Binding. BindBody is similar with Bind,
|
||||||
// but it reads the body from supplied bytes instead of req.Body.
|
// but it reads the body from supplied bytes instead of req.Body.
|
||||||
type Body interface {
|
type BindingBody interface {
|
||||||
Binding
|
Binding
|
||||||
BindBody([]byte, any) error
|
BindBody([]byte, any) error
|
||||||
}
|
}
|
||||||
|
@ -716,7 +716,7 @@ func (c *Context) ShouldBindWith(obj any, b binding.Binding) error {
|
|||||||
//
|
//
|
||||||
// NOTE: This method reads the body before binding. So you should use
|
// NOTE: This method reads the body before binding. So you should use
|
||||||
// ShouldBindWith for better performance if you need to call only once.
|
// ShouldBindWith for better performance if you need to call only once.
|
||||||
func (c *Context) ShouldBindBodyWith(obj any, bb binding.Body) (err error) {
|
func (c *Context) ShouldBindBodyWith(obj any, bb binding.BindingBody) (err error) {
|
||||||
var body []byte
|
var body []byte
|
||||||
if cb, ok := c.Get(BodyBytesKey); ok {
|
if cb, ok := c.Get(BodyBytesKey); ok {
|
||||||
if cbb, ok := cb.([]byte); ok {
|
if cbb, ok := cb.([]byte); ok {
|
||||||
|
@ -1801,7 +1801,7 @@ func TestContextShouldBindBodyWith(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tt := range []struct {
|
for _, tt := range []struct {
|
||||||
name string
|
name string
|
||||||
bindingA, bindingB binding.Body
|
bindingA, bindingB binding.BindingBody
|
||||||
bodyA, bodyB string
|
bodyA, bodyB string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user