Skip to content

Commit

Permalink
Merge pull request quarkusio#21958 from geoand/quarkusio#21956
Browse files Browse the repository at this point in the history
Allow the use of UriInfo in @ServerResponseFilter
  • Loading branch information
stuartwdouglas authored Dec 6, 2021
2 parents 7a1320f + 0b2c0c1 commit 2b6c6d9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.quarkus.resteasy.reactive.server.test.customproviders;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.core.UriInfo;

import org.jboss.resteasy.reactive.server.ServerResponseFilter;
import org.jboss.resteasy.reactive.server.SimpleResourceInfo;
Expand All @@ -14,10 +16,11 @@ public class CustomContainerResponseFilter {

@ServerResponseFilter
public void whatever(SimpleResourceInfo simplifiedResourceInfo, ContainerResponseContext responseContext,
ContainerRequestContext requestContext, Throwable t) {
ContainerRequestContext requestContext, UriInfo uriInfo, Throwable t) {
assertTrue(
PreventAbortResteasyReactiveContainerRequestContext.class.isAssignableFrom(requestContext.getClass()));
assertNull(t);
assertNotNull(uriInfo);
if (simplifiedResourceInfo != null) {
responseContext.getHeaders().putSingle("java-method", simplifiedResourceInfo.getMethodName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,11 @@ private static ResultHandle[] getResponseFilterResultHandles(MethodInfo targetMe
targetMethodParamHandles[i] = filterMethod.getMethodParam(1);
} else if (unwrappableTypes.contains(paramDotName)) {
targetMethodParamHandles[i] = GeneratorUtils.unwrapObject(filterMethod, rrReqCtxHandle, paramDotName);
} else if (URI_INFO.equals(paramDotName)) {
GeneratorUtils.paramHandleFromReqContextMethod(filterMethod, rrReqCtxHandle, targetMethodParamHandles,
i,
"getUriInfo",
URI_INFO);
} else if (RESOURCE_INFO.equals(paramDotName)) {
targetMethodParamHandles[i] = getResourceInfoHandle(filterMethod, rrReqCtxHandle);
} else if (ResteasyReactiveServerDotNames.SIMPLIFIED_RESOURCE_INFO.equals(paramDotName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ResourceInfo;
import javax.ws.rs.core.UriInfo;

/**
* When used on a method, then an implementation of {@link javax.ws.rs.container.ContainerResponseContext} is generated
Expand Down Expand Up @@ -41,6 +42,7 @@
* <li>{@link ContainerRequestContext}
* <li>{@link ContainerResponseContext}
* <li>{@link ResourceInfo}
* <li>{@link UriInfo}
* <li>{@link SimpleResourceInfo}
* <li>{@link Throwable} - The thrown exception - or {@code null} if no exception was thrown
* </ul>
Expand Down

0 comments on commit 2b6c6d9

Please sign in to comment.