Documentation ¶
Overview ¶
Package format provides formatting APIs for display processed result application did.
Index ¶
- type ResponseFormatter
- func (f *ResponseFormatter) Done() error
- func (f *ResponseFormatter) Format(s *status.Status, header, trailer metadata.MD, v interface{}) error
- func (f *ResponseFormatter) FormatHeader(header metadata.MD)
- func (f *ResponseFormatter) FormatMessage(v interface{}) error
- func (f *ResponseFormatter) FormatTrailer(status *status.Status, trailer metadata.MD) error
- type ResponseFormatterInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ResponseFormatter ¶
type ResponseFormatter struct {
// contains filtered or unexported fields
}
ResponseFormatter provides formatting feature for gRPC response.
func NewResponseFormatter ¶
func NewResponseFormatter(f ResponseFormatterInterface, enrich bool) *ResponseFormatter
NewResponseFormatter formats gRPC response with a specific formatter. If enrich is false, the formatter prints only messages. Or else, it prints all includes headers, messages, trailers and status.
func (*ResponseFormatter) Done ¶
func (f *ResponseFormatter) Done() error
func (*ResponseFormatter) FormatHeader ¶
func (f *ResponseFormatter) FormatHeader(header metadata.MD)
func (*ResponseFormatter) FormatMessage ¶
func (f *ResponseFormatter) FormatMessage(v interface{}) error
func (*ResponseFormatter) FormatTrailer ¶
type ResponseFormatterInterface ¶
type ResponseFormatterInterface interface { // FormatHeader formats the response header. FormatHeader(header metadata.MD) // FormatMessage formats the response message (body). FormatMessage(v interface{}) error // FormatStatus formats the response status. FormatStatus(status *status.Status) error // FormatTrailer formats the response trailer. FormatTrailer(trailer metadata.MD) // Done indicates all response information is formatted. // The client of ResponseFormatter should call it at the end. Done() error }
ResponseFormatterInterface is an interface for formatting gRPC response.
Click to show internal directories.
Click to hide internal directories.