MCPcopy Create free account
hub / github.com/kataras/iris / ReadJSONProtobuf

Method ReadJSONProtobuf

context/context.go:3223–3235  ·  view source on GitHub ↗

ReadJSONProtobuf reads a JSON body request into the given "ptr" proto.Message. Look `ReadProtobuf` too.

(ptr proto.Message, opts ...ProtoUnmarshalOptions)

Source from the content-addressed store, hash-verified

3221// ReadJSONProtobuf reads a JSON body request into the given "ptr" proto.Message.
3222// Look `ReadProtobuf` too.
3223func (ctx *Context) ReadJSONProtobuf(ptr proto.Message, opts ...ProtoUnmarshalOptions) error {
3224 rawData, err := ctx.GetBody()
3225 if err != nil {
3226 return err
3227 }
3228
3229 opt := defaultProtobufUnmarshalOptions
3230 if len(opts) > 0 {
3231 opt = opts[0]
3232 }
3233
3234 return opt.Unmarshal(rawData, ptr)
3235}
3236
3237// ReadMsgPack binds the request body of msgpack format to the "ptr" and returns any error.
3238func (ctx *Context) ReadMsgPack(ptr interface{}) error {

Callers 1

readFromJSONFunction · 0.80

Calls 2

GetBodyMethod · 0.95
UnmarshalMethod · 0.65

Tested by

no test coverage detected