grpc-middleware

module
v0.0.0-...-f65aa10 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: MIT

README

grpc-mask

GoDoc

A gRPC interceptor to mask errors.

This piece of middleware intends to stop sensitive information from being returned to calling services. Pass in a list of codes you wish to mask, and they shall all be returned as internal server errors, with no further information.

Go get

go get github.com/tumelohq/grpc-middleware/...

Usage

Have a look at the test, we spin up an entire client and server, and plug the middleware in.

Masking

This masks all internal and unknown errors, hiding potentially damaging and sensitive information.

interceptor := grpc.UnaryInterceptor(
    grpcmask.UnaryServerInterceptor(
        codes.Internal,
        codes.Unknown,
    ),
)
Mapping

This maps from one error to another. In this snippet we are mapping Unknown errors to Internal.

interceptor := grpc.UnaryInterceptor(
    grpcmap.UnaryServerInterceptor(map[codes.Code]codes.Code{
        codes.Unknown: codes.Internal,
    }),
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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