1
0
mirror of https://github.com/labstack/echo.git synced 2025-07-05 00:58:47 +02:00
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2019-06-27 10:52:17 -07:00
parent 858270f6f5
commit 8fb7b5be27
3 changed files with 11 additions and 12 deletions

13
bind.go
View File

@ -34,11 +34,11 @@ type (
func (b *DefaultBinder) Bind(i interface{}, c Context) (err error) {
req := c.Request()
paramNames := c.ParamNames()
paramValues := c.ParamValues()
params := make(map[string][]string)
for i, name := range paramNames {
params[name] = []string{paramValues[i]}
names := c.ParamNames()
values := c.ParamValues()
params := map[string][]string{}
for i, name := range names {
params[name] = []string{values[i]}
}
if err := b.bindData(i, params, "param"); err != nil {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
@ -88,6 +88,9 @@ func (b *DefaultBinder) Bind(i interface{}, c Context) (err error) {
}
func (b *DefaultBinder) bindData(ptr interface{}, data map[string][]string, tag string) error {
if len(data) == 0 {
return nil
}
typ := reflect.TypeOf(ptr).Elem()
val := reflect.ValueOf(ptr).Elem()