Skip to content

Commit

Permalink
tonic/handler: use strconv.ParseBool to interpret the Explode Tag, wi…
Browse files Browse the repository at this point in the history
…th true as default value.
  • Loading branch information
wI2L committed Jan 29, 2019
1 parent 1afc764 commit ad613c3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tonic/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"reflect"
"runtime"
"strconv"
"strings"
"sync"

Expand Down Expand Up @@ -194,11 +195,11 @@ func bind(c *gin.Context, v reflect.Value, tag string, extract extractor) error
}
// Set-up context for extractors.
// Query.
explode, ok := ft.Tag.Lookup(ExplodeTag)
if ok && explode == "false" {
c.Set(ExplodeTag, false)
} else {
c.Set(ExplodeTag, true)
c.Set(ExplodeTag, true) // default
if explodeVal, ok := ft.Tag.Lookup(ExplodeTag); ok {
if explode, err := strconv.ParseBool(explodeVal); err == nil && !explode {
c.Set(ExplodeTag, false)
}
}
_, fieldValues, err := extract(c, tagValue)
if err != nil {
Expand Down

0 comments on commit ad613c3

Please sign in to comment.