format

package
v0.10.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package format provides formatting APIs for display processed result application did.

Index

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) Format

func (f *ResponseFormatter) Format(s *status.Status, header, trailer metadata.MD, v interface{}) error

func (*ResponseFormatter) FormatHeader

func (f *ResponseFormatter) FormatHeader(header metadata.MD)

func (*ResponseFormatter) FormatMessage

func (f *ResponseFormatter) FormatMessage(v interface{}) error

func (*ResponseFormatter) FormatTrailer

func (f *ResponseFormatter) FormatTrailer(status *status.Status, trailer metadata.MD) error

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.

Directories

Path Synopsis
Package curl provides a curl-like formatter implementation.
Package curl provides a curl-like formatter implementation.
Package json provides a JSON formatter implementation.
Package json provides a JSON formatter implementation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL