mirror of
https://github.com/kataras/iris.git
synced 2026-01-09 04:51:56 +00:00
add context.Protobuf, MsgPack, ReadProtobuf, ReadMsgPack methods
Former-commit-id: 39d547ecfb1516505a1eb76a12a1f6e9e4111962
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/kataras/iris/v12/context"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
// binding contains the Dependency and the Input, it's the result of a function or struct + dependencies.
|
||||
@@ -344,6 +346,14 @@ func payloadBinding(index int, typ reflect.Type) *binding {
|
||||
err = ctx.ReadForm(ptr)
|
||||
case context.ContentJSONHeaderValue:
|
||||
err = ctx.ReadJSON(ptr)
|
||||
case context.ContentProtobufHeaderValue:
|
||||
if msg, ok := ptr.(proto.Message); ok {
|
||||
err = ctx.ReadProtobuf(msg)
|
||||
} else {
|
||||
err = context.ErrContentNotSupported
|
||||
}
|
||||
case context.ContentMsgPackHeaderValue, context.ContentMsgPack2HeaderValue:
|
||||
err = ctx.ReadMsgPack(ptr)
|
||||
default:
|
||||
if ctx.Request().URL.RawQuery != "" {
|
||||
// try read from query.
|
||||
|
||||
Reference in New Issue
Block a user