How to intercept grpc request message in Java ServerInterceptor?

454 views
Skip to first unread message

Mahesh Kanote

unread,
Jul 25, 2018, 2:44:39 AM7/25/18
to grpc.io
Hi,

I am able to intercept headers in server interceptor. We have common interceptor across all services. We want to make few common validations on each request in interceptor for each request coming in so is there any way to interceptgrpc request message in Java ServerInterceptor?

Thanks,
Mahesh

Carl Mastrangelo

unread,
Jul 26, 2018, 9:20:12 PM7/26/18
to grpc.io
Yes, you can do this.  In your interceptor, you return a ServerCall.Listner, which accepts request messages.  Generally, this listener just propagates the call to the ServerCall.  If you are using ForwardingServerCallListener, you can override the onMessage() method to do the validation.
Reply all
Reply to author
Forward
0 new messages