Skip to content

Commit e9c42af

Browse files
author
jvmlet
committed
readme updated with examples
1 parent e27325d commit e9c42af

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

README.adoc

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ All you need to do is to annotate your service implementation with `@org.lognet.
6565
----
6666
6767
=== Interceptors support
68-
The starter supports the registration of two kinds of interceptors:
68+
The starter supports the registration of two kinds of interceptors: _Global_ and _Per Service_. +
69+
In both cases the interceptor has to implement `io.grpc.ServerInterceptor` interface.
6970

7071
- Per service
7172
@@ -88,8 +89,25 @@ public class MyInterceptor implements ServerInterceptor{
8889
}
8990
----
9091

92+
The annotation on java config factory method is also supported :
9193

92-
In both cases the interceptor has to implement `io.grpc.ServerInterceptor` interface.
94+
[source,java]
95+
----
96+
@Configuration
97+
public class MyConfig{
98+
@Bean
99+
@GRpcGlobalInterceptor
100+
public ServerInterceptor globalInterceptor(){
101+
new ServerInterceptor(){
102+
@Override
103+
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) {
104+
// your logic here
105+
return next.startCall(call, headers);
106+
}
107+
};
108+
}
109+
}
110+
----
93111

94112
The particular service also has the opportunity to disable the global interceptors :
95113

0 commit comments

Comments
 (0)