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

Method Protobuf

context/context.go:4654–4668  ·  view source on GitHub ↗

Protobuf marshals the given "v" value of proto Message and writes its result to the client. It reports any protobuf parser or write errors back to the caller. Look the Application.SetContextErrorHandler to override the default status code 500 with a custom error response.

(v proto.Message)

Source from the content-addressed store, hash-verified

4652// Look the Application.SetContextErrorHandler to override the
4653// default status code 500 with a custom error response.
4654func (ctx *Context) Protobuf(v proto.Message) (int, error) {
4655 out, err := proto.Marshal(v)
4656 if err != nil {
4657 ctx.handleContextError(err)
4658 return 0, err
4659 }
4660
4661 ctx.ContentType(ContentProtobufHeaderValue)
4662 n, err := ctx.Write(out)
4663 if err != nil {
4664 ctx.handleContextError(err)
4665 }
4666
4667 return n, err
4668}
4669
4670// MsgPack marshals the given "v" value of msgpack format and writes its result to the client.
4671//

Callers 3

NegotiateMethod · 0.95
sendFunction · 0.45
defaultResultHandlerFunction · 0.45

Calls 4

handleContextErrorMethod · 0.95
ContentTypeMethod · 0.95
WriteMethod · 0.95
MarshalMethod · 0.65

Tested by

no test coverage detected