summaryrefslogtreecommitdiff
path: root/vendor/github.com/gin-gonic
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/gin-gonic')
-rw-r--r--vendor/github.com/gin-gonic/gin/.golangci.yml22
-rw-r--r--vendor/github.com/gin-gonic/gin/CHANGELOG.md6
-rw-r--r--vendor/github.com/gin-gonic/gin/README.md5
-rw-r--r--vendor/github.com/gin-gonic/gin/binding/form_mapping.go9
-rw-r--r--vendor/github.com/gin-gonic/gin/binding/protobuf.go9
-rw-r--r--vendor/github.com/gin-gonic/gin/binding/uri.go2
-rw-r--r--vendor/github.com/gin-gonic/gin/context.go85
-rw-r--r--vendor/github.com/gin-gonic/gin/go.mod15
-rw-r--r--vendor/github.com/gin-gonic/gin/go.sum55
-rw-r--r--vendor/github.com/gin-gonic/gin/mode.go6
-rw-r--r--vendor/github.com/gin-gonic/gin/render/json.go22
-rw-r--r--vendor/github.com/gin-gonic/gin/render/protobuf.go2
-rw-r--r--vendor/github.com/gin-gonic/gin/tree.go70
-rw-r--r--vendor/github.com/gin-gonic/gin/version.go2
14 files changed, 136 insertions, 174 deletions
diff --git a/vendor/github.com/gin-gonic/gin/.golangci.yml b/vendor/github.com/gin-gonic/gin/.golangci.yml
new file mode 100644
index 000000000..78a4259a1
--- /dev/null
+++ b/vendor/github.com/gin-gonic/gin/.golangci.yml
@@ -0,0 +1,22 @@
+run:
+ timeout: 5m
+linters:
+ enable:
+ - gofmt
+ - misspell
+ - revive
+issues:
+ exclude-rules:
+ - linters:
+ - structcheck
+ - unused
+ text: "`data` is unused"
+ - linters:
+ - staticcheck
+ text: "SA1019:"
+ - linters:
+ - revive
+ text: "var-naming:"
+ - linters:
+ - revive
+ text: "exported:"
diff --git a/vendor/github.com/gin-gonic/gin/CHANGELOG.md b/vendor/github.com/gin-gonic/gin/CHANGELOG.md
index a28edc840..308af74c3 100644
--- a/vendor/github.com/gin-gonic/gin/CHANGELOG.md
+++ b/vendor/github.com/gin-gonic/gin/CHANGELOG.md
@@ -1,5 +1,11 @@
# Gin ChangeLog
+## Gin v1.7.3
+
+### BUGFIXES
+
+* fix level 1 router match [#2767](https://github.com/gin-gonic/gin/issues/2767), [#2796](https://github.com/gin-gonic/gin/issues/2796)
+
## Gin v1.7.2
### BUGFIXES
diff --git a/vendor/github.com/gin-gonic/gin/README.md b/vendor/github.com/gin-gonic/gin/README.md
index ef8011793..198bf0119 100644
--- a/vendor/github.com/gin-gonic/gin/README.md
+++ b/vendor/github.com/gin-gonic/gin/README.md
@@ -256,14 +256,15 @@ func main() {
// For each matched request Context will hold the route definition
router.POST("/user/:name/*action", func(c *gin.Context) {
- c.FullPath() == "/user/:name/*action" // true
+ b := c.FullPath() == "/user/:name/*action" // true
+ c.String(http.StatusOK, "%t", b)
})
// This handler will add a new router for /user/groups.
// Exact routes are resolved before param routes, regardless of the order they were defined.
// Routes starting with /user/groups are never interpreted as /user/:name/... routes
router.GET("/user/groups", func(c *gin.Context) {
- c.String(http.StatusOK, "The available groups are [...]", name)
+ c.String(http.StatusOK, "The available groups are [...]")
})
router.Run(":8080")
diff --git a/vendor/github.com/gin-gonic/gin/binding/form_mapping.go b/vendor/github.com/gin-gonic/gin/binding/form_mapping.go
index cb66dd4a7..f8b4b1239 100644
--- a/vendor/github.com/gin-gonic/gin/binding/form_mapping.go
+++ b/vendor/github.com/gin-gonic/gin/binding/form_mapping.go
@@ -26,7 +26,7 @@ var (
ErrConvertToMapString = errors.New("can not convert to map of strings")
)
-func mapUri(ptr interface{}, m map[string][]string) error {
+func mapURI(ptr interface{}, m map[string][]string) error {
return mapFormByTag(ptr, m, "uri")
}
@@ -83,7 +83,7 @@ func mapping(value reflect.Value, field reflect.StructField, setter setter, tag
return false, nil
}
- var vKind = value.Kind()
+ vKind := value.Kind()
if vKind == reflect.Ptr {
var isNew bool
@@ -210,7 +210,7 @@ func setWithProperType(val string, value reflect.Value, field reflect.StructFiel
case reflect.Int64:
switch value.Interface().(type) {
case time.Duration:
- return setTimeDuration(val, value, field)
+ return setTimeDuration(val, value)
}
return setIntField(val, 64, value)
case reflect.Uint:
@@ -310,7 +310,6 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val
t := time.Unix(tv/int64(d), tv%int64(d))
value.Set(reflect.ValueOf(t))
return nil
-
}
if val == "" {
@@ -360,7 +359,7 @@ func setSlice(vals []string, value reflect.Value, field reflect.StructField) err
return nil
}
-func setTimeDuration(val string, value reflect.Value, field reflect.StructField) error {
+func setTimeDuration(val string, value reflect.Value) error {
d, err := time.ParseDuration(val)
if err != nil {
return err
diff --git a/vendor/github.com/gin-gonic/gin/binding/protobuf.go b/vendor/github.com/gin-gonic/gin/binding/protobuf.go
index f9ece928d..a4e471535 100644
--- a/vendor/github.com/gin-gonic/gin/binding/protobuf.go
+++ b/vendor/github.com/gin-gonic/gin/binding/protobuf.go
@@ -5,10 +5,11 @@
package binding
import (
+ "errors"
"io/ioutil"
"net/http"
- "github.com/golang/protobuf/proto"
+ "google.golang.org/protobuf/proto"
)
type protobufBinding struct{}
@@ -26,7 +27,11 @@ func (b protobufBinding) Bind(req *http.Request, obj interface{}) error {
}
func (protobufBinding) BindBody(body []byte, obj interface{}) error {
- if err := proto.Unmarshal(body, obj.(proto.Message)); err != nil {
+ msg, ok := obj.(proto.Message)
+ if !ok {
+ return errors.New("obj is not ProtoMessage")
+ }
+ if err := proto.Unmarshal(body, msg); err != nil {
return err
}
// Here it's same to return validate(obj), but util now we can't add
diff --git a/vendor/github.com/gin-gonic/gin/binding/uri.go b/vendor/github.com/gin-gonic/gin/binding/uri.go
index f91ec3819..a3c0df515 100644
--- a/vendor/github.com/gin-gonic/gin/binding/uri.go
+++ b/vendor/github.com/gin-gonic/gin/binding/uri.go
@@ -11,7 +11,7 @@ func (uriBinding) Name() string {
}
func (uriBinding) BindUri(m map[string][]string, obj interface{}) error {
- if err := mapUri(obj, m); err != nil {
+ if err := mapURI(obj, m); err != nil {
return err
}
return validate(obj)
diff --git a/vendor/github.com/gin-gonic/gin/context.go b/vendor/github.com/gin-gonic/gin/context.go
index ecf74ba9b..62849488b 100644
--- a/vendor/github.com/gin-gonic/gin/context.go
+++ b/vendor/github.com/gin-gonic/gin/context.go
@@ -383,6 +383,15 @@ func (c *Context) Param(key string) string {
return c.Params.ByName(key)
}
+// AddParam adds param to context and
+// replaces path param key with given value for e2e testing purposes
+// Example Route: "/user/:id"
+// AddParam("id", 1)
+// Result: "/user/1"
+func (c *Context) AddParam(key, value string) {
+ c.Params = append(c.Params, Param{Key: key, Value: value})
+}
+
// Query returns the keyed url query value if it exists,
// otherwise it returns an empty string `("")`.
// It is shortcut for `c.Request.URL.Query().Get(key)`
@@ -391,9 +400,9 @@ func (c *Context) Param(key string) string {
// c.Query("name") == "Manu"
// c.Query("value") == ""
// c.Query("wtf") == ""
-func (c *Context) Query(key string) string {
- value, _ := c.GetQuery(key)
- return value
+func (c *Context) Query(key string) (value string) {
+ value, _ = c.GetQuery(key)
+ return
}
// DefaultQuery returns the keyed url query value if it exists,
@@ -427,9 +436,9 @@ func (c *Context) GetQuery(key string) (string, bool) {
// QueryArray returns a slice of strings for a given query key.
// The length of the slice depends on the number of params with the given key.
-func (c *Context) QueryArray(key string) []string {
- values, _ := c.GetQueryArray(key)
- return values
+func (c *Context) QueryArray(key string) (values []string) {
+ values, _ = c.GetQueryArray(key)
+ return
}
func (c *Context) initQueryCache() {
@@ -444,18 +453,16 @@ func (c *Context) initQueryCache() {
// GetQueryArray returns a slice of strings for a given query key, plus
// a boolean value whether at least one value exists for the given key.
-func (c *Context) GetQueryArray(key string) ([]string, bool) {
+func (c *Context) GetQueryArray(key string) (values []string, ok bool) {
c.initQueryCache()
- if values, ok := c.queryCache[key]; ok && len(values) > 0 {
- return values, true
- }
- return []string{}, false
+ values, ok = c.queryCache[key]
+ return
}
// QueryMap returns a map for a given query key.
-func (c *Context) QueryMap(key string) map[string]string {
- dicts, _ := c.GetQueryMap(key)
- return dicts
+func (c *Context) QueryMap(key string) (dicts map[string]string) {
+ dicts, _ = c.GetQueryMap(key)
+ return
}
// GetQueryMap returns a map for a given query key, plus a boolean value
@@ -467,9 +474,9 @@ func (c *Context) GetQueryMap(key string) (map[string]string, bool) {
// PostForm returns the specified key from a POST urlencoded form or multipart form
// when it exists, otherwise it returns an empty string `("")`.
-func (c *Context) PostForm(key string) string {
- value, _ := c.GetPostForm(key)
- return value
+func (c *Context) PostForm(key string) (value string) {
+ value, _ = c.GetPostForm(key)
+ return
}
// DefaultPostForm returns the specified key from a POST urlencoded form or multipart form
@@ -498,9 +505,9 @@ func (c *Context) GetPostForm(key string) (string, bool) {
// PostFormArray returns a slice of strings for a given form key.
// The length of the slice depends on the number of params with the given key.
-func (c *Context) PostFormArray(key string) []string {
- values, _ := c.GetPostFormArray(key)
- return values
+func (c *Context) PostFormArray(key string) (values []string) {
+ values, _ = c.GetPostFormArray(key)
+ return
}
func (c *Context) initFormCache() {
@@ -518,18 +525,16 @@ func (c *Context) initFormCache() {
// GetPostFormArray returns a slice of strings for a given form key, plus
// a boolean value whether at least one value exists for the given key.
-func (c *Context) GetPostFormArray(key string) ([]string, bool) {
+func (c *Context) GetPostFormArray(key string) (values []string, ok bool) {
c.initFormCache()
- if values := c.formCache[key]; len(values) > 0 {
- return values, true
- }
- return []string{}, false
+ values, ok = c.formCache[key]
+ return
}
// PostFormMap returns a map for a given form key.
-func (c *Context) PostFormMap(key string) map[string]string {
- dicts, _ := c.GetPostFormMap(key)
- return dicts
+func (c *Context) PostFormMap(key string) (dicts map[string]string) {
+ dicts, _ = c.GetPostFormMap(key)
+ return
}
// GetPostFormMap returns a map for a given form key, plus a boolean value
@@ -1161,22 +1166,28 @@ func (c *Context) SetAccepted(formats ...string) {
/***** GOLANG.ORG/X/NET/CONTEXT *****/
/************************************/
-// Deadline always returns that there is no deadline (ok==false),
-// maybe you want to use Request.Context().Deadline() instead.
+// Deadline returns that there is no deadline (ok==false) when c.Request has no Context.
func (c *Context) Deadline() (deadline time.Time, ok bool) {
- return
+ if c.Request == nil || c.Request.Context() == nil {
+ return
+ }
+ return c.Request.Context().Deadline()
}
-// Done always returns nil (chan which will wait forever),
-// if you want to abort your work when the connection was closed
-// you should use Request.Context().Done() instead.
+// Done returns nil (chan which will wait forever) when c.Request has no Context.
func (c *Context) Done() <-chan struct{} {
- return nil
+ if c.Request == nil || c.Request.Context() == nil {
+ return nil
+ }
+ return c.Request.Context().Done()
}
-// Err always returns nil, maybe you want to use Request.Context().Err() instead.
+// Err returns nil when c.Request has no Context.
func (c *Context) Err() error {
- return nil
+ if c.Request == nil || c.Request.Context() == nil {
+ return nil
+ }
+ return c.Request.Context().Err()
}
// Value returns the value associated with this context for key, or nil
diff --git a/vendor/github.com/gin-gonic/gin/go.mod b/vendor/github.com/gin-gonic/gin/go.mod
deleted file mode 100644
index 9484b2644..000000000
--- a/vendor/github.com/gin-gonic/gin/go.mod
+++ /dev/null
@@ -1,15 +0,0 @@
-module github.com/gin-gonic/gin
-
-go 1.13
-
-require (
- github.com/gin-contrib/sse v0.1.0
- github.com/go-playground/validator/v10 v10.6.1
- github.com/goccy/go-json v0.5.1
- github.com/golang/protobuf v1.3.3
- github.com/json-iterator/go v1.1.9
- github.com/mattn/go-isatty v0.0.12
- github.com/stretchr/testify v1.4.0
- github.com/ugorji/go/codec v1.2.6
- gopkg.in/yaml.v2 v2.2.8
-)
diff --git a/vendor/github.com/gin-gonic/gin/go.sum b/vendor/github.com/gin-gonic/gin/go.sum
deleted file mode 100644
index e61ef908a..000000000
--- a/vendor/github.com/gin-gonic/gin/go.sum
+++ /dev/null
@@ -1,55 +0,0 @@
-github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
-github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
-github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
-github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
-github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
-github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
-github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
-github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
-github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
-github.com/go-playground/validator/v10 v10.6.1 h1:W6TRDXt4WcWp4c4nf/G+6BkGdhiIo0k417gfr+V6u4I=
-github.com/go-playground/validator/v10 v10.6.1/go.mod h1:xm76BBt941f7yWdGnI2DVPFFg1UK3YY04qifoXU3lOk=
-github.com/goccy/go-json v0.5.1 h1:R9UYTOUvo7eIY9aeDMZ4L6OVtHaSr1k2No9W6MKjXrA=
-github.com/goccy/go-json v0.5.1/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
-github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
-github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
-github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
-github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
-github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
-github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
-github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
-github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
-github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
-github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
-github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
-github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
-github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
-github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
-github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
-github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
-github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
-github.com/ugorji/go v1.2.6 h1:tGiWC9HENWE2tqYycIqFTNorMmFRVhNwCpDOpWqnk8E=
-github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0=
-github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ=
-github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw=
-golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
-golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
-golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
-golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
-golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
-gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/vendor/github.com/gin-gonic/gin/mode.go b/vendor/github.com/gin-gonic/gin/mode.go
index c8813aff2..4d199df30 100644
--- a/vendor/github.com/gin-gonic/gin/mode.go
+++ b/vendor/github.com/gin-gonic/gin/mode.go
@@ -41,8 +41,10 @@ var DefaultWriter io.Writer = os.Stdout
// DefaultErrorWriter is the default io.Writer used by Gin to debug errors
var DefaultErrorWriter io.Writer = os.Stderr
-var ginMode = debugCode
-var modeName = DebugMode
+var (
+ ginMode = debugCode
+ modeName = DebugMode
+)
func init() {
mode := os.Getenv(EnvGinMode)
diff --git a/vendor/github.com/gin-gonic/gin/render/json.go b/vendor/github.com/gin-gonic/gin/render/json.go
index e25415b00..3ebcee970 100644
--- a/vendor/github.com/gin-gonic/gin/render/json.go
+++ b/vendor/github.com/gin-gonic/gin/render/json.go
@@ -49,7 +49,7 @@ type PureJSON struct {
var (
jsonContentType = []string{"application/json; charset=utf-8"}
jsonpContentType = []string{"application/javascript; charset=utf-8"}
- jsonAsciiContentType = []string{"application/json"}
+ jsonASCIIContentType = []string{"application/json"}
)
// Render (JSON) writes data with custom ContentType.
@@ -102,8 +102,7 @@ func (r SecureJSON) Render(w http.ResponseWriter) error {
// if the jsonBytes is array values
if bytes.HasPrefix(jsonBytes, bytesconv.StringToBytes("[")) && bytes.HasSuffix(jsonBytes,
bytesconv.StringToBytes("]")) {
- _, err = w.Write(bytesconv.StringToBytes(r.Prefix))
- if err != nil {
+ if _, err = w.Write(bytesconv.StringToBytes(r.Prefix)); err != nil {
return err
}
}
@@ -130,20 +129,19 @@ func (r JsonpJSON) Render(w http.ResponseWriter) (err error) {
}
callback := template.JSEscapeString(r.Callback)
- _, err = w.Write(bytesconv.StringToBytes(callback))
- if err != nil {
+ if _, err = w.Write(bytesconv.StringToBytes(callback)); err != nil {
return err
}
- _, err = w.Write(bytesconv.StringToBytes("("))
- if err != nil {
+
+ if _, err = w.Write(bytesconv.StringToBytes("(")); err != nil {
return err
}
- _, err = w.Write(ret)
- if err != nil {
+
+ if _, err = w.Write(ret); err != nil {
return err
}
- _, err = w.Write(bytesconv.StringToBytes(");"))
- if err != nil {
+
+ if _, err = w.Write(bytesconv.StringToBytes(");")); err != nil {
return err
}
@@ -178,7 +176,7 @@ func (r AsciiJSON) Render(w http.ResponseWriter) (err error) {
// WriteContentType (AsciiJSON) writes JSON ContentType.
func (r AsciiJSON) WriteContentType(w http.ResponseWriter) {
- writeContentType(w, jsonAsciiContentType)
+ writeContentType(w, jsonASCIIContentType)
}
// Render (PureJSON) writes custom ContentType and encodes the given interface object.
diff --git a/vendor/github.com/gin-gonic/gin/render/protobuf.go b/vendor/github.com/gin-gonic/gin/render/protobuf.go
index 15aca9959..1d2aa871c 100644
--- a/vendor/github.com/gin-gonic/gin/render/protobuf.go
+++ b/vendor/github.com/gin-gonic/gin/render/protobuf.go
@@ -7,7 +7,7 @@ package render
import (
"net/http"
- "github.com/golang/protobuf/proto"
+ "google.golang.org/protobuf/proto"
)
// ProtoBuf contains the given interface object.
diff --git a/vendor/github.com/gin-gonic/gin/tree.go b/vendor/github.com/gin-gonic/gin/tree.go
index 2e46b8e51..fb0a5935c 100644
--- a/vendor/github.com/gin-gonic/gin/tree.go
+++ b/vendor/github.com/gin-gonic/gin/tree.go
@@ -101,8 +101,7 @@ func countParams(path string) uint16 {
type nodeType uint8
const (
- static nodeType = iota // default
- root
+ root nodeType = iota + 1
param
catchAll
)
@@ -400,23 +399,10 @@ type nodeValue struct {
// made if a handle exists with an extra (without the) trailing slash for the
// given path.
func (n *node) getValue(path string, params *Params, unescape bool) (value nodeValue) {
- // path: /abc/123/def
- // level 1 router:abc
- // level 2 router:123
- // level 3 router:def
var (
skippedPath string
- latestNode = n // not found `level 2 router` use latestNode
-
- // match '/' count
- // matchNum < 1: `level 2 router` not found,the current node needs to be equal to latestNode
- // matchNum >= 1: `level (2 or 3 or 4 or ...) router`: Normal handling
- matchNum int // each match will accumulate
+ latestNode = n // Caching the latest node
)
- //if path == "/", no need to look for tree node
- if len(path) == 1 {
- matchNum = 1
- }
walk: // Outer loop for walking the tree
for {
@@ -444,17 +430,13 @@ walk: // Outer loop for walking the tree
}
n = n.children[i]
-
- // match '/', If this condition is matched, the next route is found
- if (len(n.fullPath) != 0 && n.wildChild) || path[len(path)-1] == '/' {
- matchNum++
- }
continue walk
}
}
-
- // level 2 router not found,the current node needs to be equal to latestNode
- if matchNum < 1 {
+ // If the path at the end of the loop is not equal to '/' and the current node has no child nodes
+ // the current node needs to be equal to the latest matching node
+ matched := path != "/" && !n.wildChild
+ if matched {
n = latestNode
}
@@ -472,6 +454,16 @@ walk: // Outer loop for walking the tree
switch n.nType {
case param:
+ // fix truncate the parameter
+ // tree_test.go line: 204
+ if matched {
+ path = prefix + path
+ // The saved path is used after the prefix route is intercepted by matching
+ if n.indices == "/" {
+ path = skippedPath[1:]
+ }
+ }
+
// Find param end (either '/' or path end)
end := 0
for end < len(path) && path[end] != '/' {
@@ -503,18 +495,6 @@ walk: // Outer loop for walking the tree
if len(n.children) > 0 {
path = path[end:]
n = n.children[0]
- // next node,the latestNode needs to be equal to currentNode and handle next router
- latestNode = n
- // not found router in (level 1 router and handle next node),skippedPath cannot execute
- // example:
- // * /:cc/cc
- // call /a/cc expectations:match/200 Actual:match/200
- // call /a/dd expectations:unmatch/404 Actual: panic
- // call /addr/dd/aa expectations:unmatch/404 Actual: panic
- // skippedPath: It can only be executed if the secondary route is not found
- // matchNum: Go to the next level of routing tree node search,need add matchNum
- skippedPath = ""
- matchNum++
continue walk
}
@@ -567,8 +547,9 @@ walk: // Outer loop for walking the tree
}
if path == prefix {
- // level 2 router not found and latestNode.wildChild is true
- if matchNum < 1 && latestNode.wildChild {
+ // If the current path does not equal '/' and the node does not have a registered handle and the most recently matched node has a child node
+ // the current node needs to be equal to the latest matching node
+ if latestNode.wildChild && n.handlers == nil && path != "/" {
n = latestNode.children[len(latestNode.children)-1]
}
// We should have reached the node containing the handle.
@@ -600,10 +581,17 @@ walk: // Outer loop for walking the tree
return
}
- // path != "/" && skippedPath != ""
- if len(path) != 1 && len(skippedPath) > 0 && strings.HasSuffix(skippedPath, path) {
+ if path != "/" && len(skippedPath) > 0 && strings.HasSuffix(skippedPath, path) {
path = skippedPath
- n = latestNode
+ // Reduce the number of cycles
+ n, latestNode = latestNode, n
+ // skippedPath cannot execute
+ // example:
+ // * /:cc/cc
+ // call /a/cc expectations:match/200 Actual:match/200
+ // call /a/dd expectations:unmatch/404 Actual: panic
+ // call /addr/dd/aa expectations:unmatch/404 Actual: panic
+ // skippedPath: It can only be executed if the secondary route is not found
skippedPath = ""
continue walk
}
diff --git a/vendor/github.com/gin-gonic/gin/version.go b/vendor/github.com/gin-gonic/gin/version.go
index a80ab69a8..535bfc827 100644
--- a/vendor/github.com/gin-gonic/gin/version.go
+++ b/vendor/github.com/gin-gonic/gin/version.go
@@ -5,4 +5,4 @@
package gin
// Version is the current gin framework's version.
-const Version = "v1.7.2"
+const Version = "v1.7.3"