0

I have a requirement where i don't want to execute interceptors for all the rpc methods, How i can set the interceptors conditionally? looking for something similarly. https://chenyitian.gitbooks.io/gin-tutorials/content/tdd/21.html execute interceptors for few routes

user1844634
  • 1,221
  • 2
  • 17
  • 35

1 Answers1

0

The interceptors all have access to the RPC method string (in the format of /package.service/method). https://github.com/grpc/grpc-go/blob/master/interceptor.go#L43

You can check the method string before executing the interceptor body.

menghanl
  • 751
  • 6
  • 7
  • i need to write the if else case in the interceptor, instead of that can i group methods based on the interceptor, same way we can group the middleware in gin . https://stackoverflow.com/questions/42373423/how-to-add-multiple-groups-to-gin-routing-for-api-version-inheritance – user1844634 Nov 19 '20 at 12:41