Created
March 11, 2022 15:45
-
-
Save harunpeksen/2112bb048956a45e6974adc8fabd2b64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func exampleUnaryClientInterceptor(ctx context.Context, method string, req, reply interface{}, | |
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { | |
// Codes before executing GRPC | |
log.Println("Some messages before execution") | |
// usual invocation of the remote method | |
err := invoker(ctx, method, req, reply, cc, opts...) | |
// Codes after executing GRPC | |
log.Println("Some messages after execution") | |
return err | |
} | |
func main() { | |
... | |
// Setting up a gRPC connection | |
conn, err := grpc.Dial(address, grpc.WithInsecure(),grpc.WithUnaryInterceptor(exampleUnaryClientInterceptor)) | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment