1
0

Updated echo to use the latest version

This commit is contained in:
kolaente
2019-06-28 09:01:50 +02:00
parent 9930f98f8e
commit 5d3b6573ca
21 changed files with 288 additions and 54 deletions

View File

@ -34,17 +34,14 @@ 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 in, name := range paramNames {
params[name] = []string{paramValues[in]}
names := c.ParamNames()
values := c.ParamValues()
params := map[string][]string{}
for i, name := range names {
params[name] = []string{values[i]}
}
// Only bind the params to the struct if there is something to bind
if len(params) > 0 {
if err := b.bindData(i, params, "param"); err != nil {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
if err := b.bindData(i, params, "param"); err != nil {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
if req.ContentLength == 0 {
@ -91,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()