mirror of https://github.com/gofiber/fiber.git
move internal/reflectunsafe into internal/bind
parent
ffc1c41d4a
commit
9887ac5979
|
@ -6,7 +6,7 @@ import (
|
|||
"reflect"
|
||||
"sync"
|
||||
|
||||
"github.com/gofiber/fiber/v3/internal/reflectunsafe"
|
||||
"github.com/gofiber/fiber/v3/internal/bind"
|
||||
"github.com/gofiber/fiber/v3/utils"
|
||||
)
|
||||
|
||||
|
@ -165,7 +165,7 @@ func (b *Bind) Validate() *Bind {
|
|||
}
|
||||
|
||||
func (b *Bind) reqDecode(v any) error {
|
||||
rv, typeID := reflectunsafe.ValueAndTypeID(v)
|
||||
rv, typeID := bind.ValueAndTypeID(v)
|
||||
if rv.Kind() != reflect.Pointer || rv.IsNil() {
|
||||
return &InvalidBinderError{Type: reflect.TypeOf(v)}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ func (b *Bind) reqDecode(v any) error {
|
|||
}
|
||||
|
||||
func (b *Bind) formDecode(v any) error {
|
||||
rv, typeID := reflectunsafe.ValueAndTypeID(v)
|
||||
rv, typeID := bind.ValueAndTypeID(v)
|
||||
if rv.Kind() != reflect.Pointer || rv.IsNil() {
|
||||
return &InvalidBinderError{Type: reflect.TypeOf(v)}
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ func (b *Bind) formDecode(v any) error {
|
|||
}
|
||||
|
||||
func (b *Bind) multipartDecode(v any) error {
|
||||
rv, typeID := reflectunsafe.ValueAndTypeID(v)
|
||||
rv, typeID := bind.ValueAndTypeID(v)
|
||||
if rv.Kind() != reflect.Pointer || rv.IsNil() {
|
||||
return &InvalidBinderError{Type: reflect.TypeOf(v)}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package reflectunsafe
|
||||
package bind
|
||||
|
||||
import (
|
||||
"reflect"
|
|
@ -0,0 +1,16 @@
|
|||
package bind_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gofiber/fiber/v3/internal/bind"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestTypeID(t *testing.T) {
|
||||
_, intType := bind.ValueAndTypeID(int(1))
|
||||
_, uintType := bind.ValueAndTypeID(uint(1))
|
||||
_, shouldBeIntType := bind.ValueAndTypeID(int(1))
|
||||
require.NotEqual(t, intType, uintType)
|
||||
require.Equal(t, intType, shouldBeIntType)
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package reflectunsafe_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gofiber/fiber/v3/internal/reflectunsafe"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestTypeID(t *testing.T) {
|
||||
_, intType := reflectunsafe.ValueAndTypeID(int(1))
|
||||
_, uintType := reflectunsafe.ValueAndTypeID(uint(1))
|
||||
_, shouldBeIntType := reflectunsafe.ValueAndTypeID(int(1))
|
||||
require.NotEqual(t, intType, uintType)
|
||||
require.Equal(t, intType, shouldBeIntType)
|
||||
}
|
Loading…
Reference in New Issue