quarkiverse / quarkus-qute-web

Automatically expose Qute templates via HTTP
Apache License 2.0
4 stars 5 forks source link

Filters are not working in qute web views #74

Closed kucharzyk closed 5 months ago

kucharzyk commented 5 months ago

I've created pretty standard filters for my application. They are working fine for standard rest easy endpoints but not for qute web views.

import io.quarkus.logging.Log;
import jakarta.ws.rs.Priorities;
import jakarta.ws.rs.container.ContainerRequestContext;
import jakarta.ws.rs.container.ContainerResponseContext;
import jakarta.ws.rs.core.Request;
import org.jboss.resteasy.reactive.server.ServerRequestFilter;
import org.jboss.resteasy.reactive.server.ServerResponseFilter;

public class SampleFilters {

    @ServerRequestFilter(priority = Priorities.AUTHENTICATION)
    public void filterRequest(ContainerRequestContext requestContext, Request req) {
        Log.warn("request filter");
    }

    @ServerResponseFilter(priority = Priorities.AUTHENTICATION)
    public void filterResponse(ContainerResponseContext responseContext) {
        Log.warn("response filter");
    }

}

This filter is not invoked at all for any qute views. I was expecting they will behave like normal rest easy endpoints.

mkouba commented 5 months ago

Well, the resteasy-reactive filters are indeed not used for routes registered by qute-web. They're only applied to JAX-RS resources. You would need to register a filter in an @Observes io.quarkus.vertx.http.runtime.filters.Filters method or a @RouteFilter method (from the reactive-routes extension) in order to apply the same logic for any route (including the JAX-RS resources).

mkouba commented 5 months ago

I'm going to close this one because quarkus-qute-web is not built on top of resteasy-reactive or JAX-RS in general.