Documentation ¶
Overview ¶
`skip` allow users to skip interceptors in certain condition.
Users can use grpc type, service name, method name and metadata to determine whether to skip the interceptor.
Example (Initialization) ¶
Simple example of skipping auth interceptor in the reflection method.
package main import ( "context" "google.golang.org/grpc" "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors" "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/auth" "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/skip" ) // Simple example of skipping auth interceptor in the reflection method. func main() { _ = grpc.NewServer( grpc.UnaryInterceptor(skip.UnaryServerInterceptor(auth.UnaryServerInterceptor(dummyAuth), SkipReflectionService)), grpc.StreamInterceptor(skip.StreamServerInterceptor(auth.StreamServerInterceptor(dummyAuth), SkipReflectionService)), ) } func dummyAuth(ctx context.Context) (context.Context, error) { return ctx, nil } func SkipReflectionService(_ context.Context, _ interceptors.GRPCType, service string, _ string) bool { return service != "grpc.reflection.v1alpha.ServerReflection" }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StreamServerInterceptor ¶
func StreamServerInterceptor(in grpc.StreamServerInterceptor, filter Filter) grpc.StreamServerInterceptor
StreamServerInterceptor returns a new streaming server interceptor that determines whether to skip the input interceptor.
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(in grpc.UnaryServerInterceptor, filter Filter) grpc.UnaryServerInterceptor
UnaryServerInterceptor returns a new unary server interceptor that determines whether to skip the input interceptor.
Types ¶
Click to show internal directories.
Click to hide internal directories.