Web filters not invoked for /q/health endpoints

87 Views Asked by At

I'm working on a multi tenant application in Quarkus where I have a ContainerRequestFilter to resolve the tenant context of an incoming request. This works as it should for my application endpoints.

I would also like to implement tenant specific health checks. However, I've noticed that my tenant context filter is not being invoked for request to /q/health endpoints (probably generally for /q) I guess this is, as these are "special" endpoints which are more seperated from the application configuration.

Is there a way that I can register a web filter for these "system" endpoints, so I can have a tenant context when invoking a health check?

1

There are 1 best solutions below

2
On BEST ANSWER

Endpoints under /q/ are not implemented in JAX-RS (Jakarta REST nowdays), but use Pure Vert.x instead.

Therefore their invocation cannot be "filtered" via JAX-RS ContainerRequestFilter.

You can instead try the Quarkus specific @RouteFilter as explained here.

It would look something like:

public class SomeFilter {

    @RouteFilter(1000) 
    void myFilter(RoutingContext rc) {
       // do something
       rc.next(); // continue the request chain 
    }
}