使用GRPC服务器拦截器验证请求

使用GRPC服务器拦截器验证请求

问题描述:

我需要使用拦截器来验证并记录一些grpc服务请求的数据.我检查了ServerInterceptor的interceptCall,但找不到获取请求对象的方法.有什么办法可以在拦截器中获取请求对象?

I need to validate and log some of the data of grpc service request using an interceptor. I checked interceptCall of ServerInterceptor and could not find a way to get the request object. Is there any way to get the request object inside an interceptor ?

您需要返回并扩展 ForwardingServerCallListener 并收听 ServerCall.Listener.onMessage()回调.

You need to return and extend a ForwardingServerCallListener and listen to the ServerCall.Listener.onMessage() callback.