Search code examples
javaheadergrpcinterceptorquarkus

How do I read a custom header in a GRPC server side service in Quarkus?


I have seen some java examples of how to write a ServerInterceptor to read a custom header from the metadata, but can't find anything on how to attach the interceptor to the service in Quarkus e.g. for this: https://quarkus.io/guides/grpc-service-implementation Or is there another, easier way of reading a custom header in Quarkus, e.g. to get a token?


Solution

  • I got this useful example in the Quarkus Zulip chat from a friendly user:

    https://github.com/quarkusio/quarkus/blob/master/integration-tests/grpc-interceptors/src/main/java/io/quarkus/grpc/examples/interceptors/HeaderServerInterceptor.java

    No need to attach or register the interceptor anywhere.