support bind uri param (#1612)

* support bind uri (1)

* uri binding successful run

* fix vet warning: github.com/gin-gonic/gin/internal.Param composite literal uses unkeyed fields

* fix code style

* update function name

* fix test function signature

* add test for CanSet

* update readme and add test case

* remove internal.Params

* add coverage

* fix warning
This commit is contained in:
thinkerou
2018-11-22 09:29:48 +08:00
committed by Bo-Yi Wu
parent 7ec82ee894
commit 521d06c81d
8 changed files with 158 additions and 31 deletions

View File

@ -36,6 +36,13 @@ type BindingBody interface {
BindBody([]byte, interface{}) error
}
// BindingUri adds BindUri method to Binding. BindUri is similar with Bind,
// but it read the Params.
type BindingUri interface {
Name() string
BindUri(map[string][]string, interface{}) error
}
// StructValidator is the minimal interface which needs to be implemented in
// order for it to be used as the validator engine for ensuring the correctness
// of the request. Gin provides a default implementation for this using
@ -70,6 +77,7 @@ var (
ProtoBuf = protobufBinding{}
MsgPack = msgpackBinding{}
YAML = yamlBinding{}
Uri = uriBinding{}
)
// Default returns the appropriate Binding instance based on the HTTP method