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)
| 4652 | // Look the Application.SetContextErrorHandler to override the |
| 4653 | // default status code 500 with a custom error response. |
| 4654 | func (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 | // |
no test coverage detected