grpc-dart icon indicating copy to clipboard operation
grpc-dart copied to clipboard

[Feature Request] server-side "wrapper" interceptors

Open cbatson opened this issue 2 years ago • 3 comments

Hello, I'd like to see something like Interceptors on the server side, but more akin to the UnaryInterceptor of gRPC-Web. This is something I have appreciated from other server frameworks. This style of interceptor would "wrap" around the service call, which yields the existing functionality of Interceptors (such as vetoing a request) and more. Such "wrapping" interceptors would be able to manipulate both the incoming request as well as the outgoing response.

There are several interesting use cases for this. One such use case would be instrumenting all service calls in a uniform way.

Interceptor 1
|   Interceptor 2
|   |   Interceptor 3
|   |   |   service call
|   |   Interceptor 3
|   Interceptor 2
Interceptor 1

cbatson avatar Dec 03 '22 07:12 cbatson

I think it makes sense to deprecate current interceptor functionality and align client and server interceptor APIs. Feel free to contribute PR with the implementation.

mraleph avatar Dec 12 '22 08:12 mraleph

Note to self, consider addressing #546 when implementing this.

cbatson avatar Dec 18 '22 21:12 cbatson

A server-side interceptor could possibly add CORS headers to a response, fixing #611

Levi-Lesches avatar Mar 30 '23 19:03 Levi-Lesches