Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithAddr ¶
func WithAddr(addr string) func(*grpcJsonInterceptorOptions)
WithAddr sets the address for the GrpcJsonInterceptor.
Example:
interceptor, err := NewGrpcJsonInterceptor(WithAddr("localhost:8080"))
func WithFilename ¶
func WithFilename(filename string) func(*grpcJsonInterceptorOptions)
WithFilename sets the filename for the GrpcJsonInterceptor.
Example:
interceptor, err := NewGrpcJsonInterceptor(WithFilename("grpc_messages.json"))
Types ¶
type GrpcJsonInterceptor ¶
type GrpcJsonInterceptor struct {
// contains filtered or unexported fields
}
GrpcJsonInterceptor intercepts gRPC calls and logs the request and response messages as JSON to a file. It also serves a web viewer for the logged messages.
func NewGrpcJsonInterceptor ¶
func NewGrpcJsonInterceptor(options ...func(*grpcJsonInterceptorOptions)) (*GrpcJsonInterceptor, error)
NewGrpcJsonInterceptor creates a new GrpcJsonInterceptor instance.
It can be configured using the environment variables: - GRPC_JSON_SNIFFER_FILE: enables JSON logging to a specified file. - GRPC_JSON_SNIFFER_ADDR: enables serving the web viewer at a specified address.
Alternatively, it can be configured through options: - WithFilename: enables JSON logging to a specified file. - WithAddr: enables serving the web viewer at a specified address.
func (*GrpcJsonInterceptor) StreamClientInterceptor ¶
func (i *GrpcJsonInterceptor) StreamClientInterceptor() grpc.StreamClientInterceptor
StreamClientInterceptor returns a gRPC stream client interceptor that logs the request and response messages as JSON.
func (*GrpcJsonInterceptor) StreamServerInterceptor ¶
func (i *GrpcJsonInterceptor) StreamServerInterceptor() func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error
StreamServerInterceptor returns a gRPC stream server interceptor that logs the request and response messages as JSON.
func (*GrpcJsonInterceptor) UnaryClientInterceptor ¶
func (i *GrpcJsonInterceptor) UnaryClientInterceptor() grpc.UnaryClientInterceptor
UnaryClientInterceptor returns a gRPC unary client interceptor that logs the request and response messages as JSON.
func (*GrpcJsonInterceptor) UnaryServerInterceptor ¶
func (i *GrpcJsonInterceptor) UnaryServerInterceptor() func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
UnaryServerInterceptor returns a gRPC unary server interceptor that logs the request and response messages as JSON.
type GrpcWebViewer ¶
type GrpcWebViewer struct {
// contains filtered or unexported fields
}
func NewGrpcWebViewer ¶
func NewGrpcWebViewer(addr string, messages string) *GrpcWebViewer
func (*GrpcWebViewer) Serve ¶
func (v *GrpcWebViewer) Serve()
func (*GrpcWebViewer) ServeHTTP ¶
func (v *GrpcWebViewer) ServeHTTP(w http.ResponseWriter, r *http.Request)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
grpc-json-sniffer-viewer
command
|
|
|
example
|
|
|
client
command
|
|
|
server
command
|
