summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack/echo/v4/bind.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-09-07 22:46:58 +0200
committerGitHub <noreply@github.com>2019-09-07 22:46:58 +0200
commita3bee01e0af3394c19360b98fd2db1b647f49299 (patch)
treeffc5778361d55d592a718354a37c9251e75fc7f6 /vendor/github.com/labstack/echo/v4/bind.go
parent1dc93ec4f001edd01daccbe408767d4878be25a3 (diff)
downloadmatterbridge-msglm-a3bee01e0af3394c19360b98fd2db1b647f49299.tar.gz
matterbridge-msglm-a3bee01e0af3394c19360b98fd2db1b647f49299.tar.bz2
matterbridge-msglm-a3bee01e0af3394c19360b98fd2db1b647f49299.zip
Update dependencies (#886)
Diffstat (limited to 'vendor/github.com/labstack/echo/v4/bind.go')
-rw-r--r--vendor/github.com/labstack/echo/v4/bind.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/vendor/github.com/labstack/echo/v4/bind.go b/vendor/github.com/labstack/echo/v4/bind.go
index 07d8034c..959a314c 100644
--- a/vendor/github.com/labstack/echo/v4/bind.go
+++ b/vendor/github.com/labstack/echo/v4/bind.go
@@ -33,6 +33,17 @@ type (
// Bind implements the `Binder#Bind` function.
func (b *DefaultBinder) Bind(i interface{}, c Context) (err error) {
req := c.Request()
+
+ 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)
+ }
+
if req.ContentLength == 0 {
if req.Method == http.MethodGet || req.Method == http.MethodDelete {
if err = b.bindData(i, c.QueryParams(), "query"); err != nil {
@@ -77,9 +88,19 @@ func (b *DefaultBinder) Bind(i interface{}, c Context) (err error) {
}
func (b *DefaultBinder) bindData(ptr interface{}, data map[string][]string, tag string) error {
+ if ptr == nil || len(data) == 0 {
+ return nil
+ }
typ := reflect.TypeOf(ptr).Elem()
val := reflect.ValueOf(ptr).Elem()
+ if m, ok := ptr.(*map[string]interface{}); ok {
+ for k, v := range data {
+ (*m)[k] = v[0]
+ }
+ return nil
+ }
+
if typ.Kind() != reflect.Struct {
return errors.New("binding element must be a struct")
}