Commit 1fe28af3 by Dave Syer

Fix issue with forward:... routes

We have to ensure that the ZuulController is not mapped on a forward otherwise we just go back through the same code path and render nothing.
parent 6d559102
......@@ -29,11 +29,11 @@ import org.springframework.cloud.netflix.zuul.filters.RouteLocator;
import org.springframework.cloud.netflix.zuul.filters.SimpleRouteLocator;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter;
import org.springframework.cloud.netflix.zuul.filters.post.SendForwardFilter;
import org.springframework.cloud.netflix.zuul.filters.post.SendResponseFilter;
import org.springframework.cloud.netflix.zuul.filters.pre.DebugFilter;
import org.springframework.cloud.netflix.zuul.filters.pre.FormBodyWrapperFilter;
import org.springframework.cloud.netflix.zuul.filters.pre.Servlet30WrapperFilter;
import org.springframework.cloud.netflix.zuul.filters.route.SendForwardFilter;
import org.springframework.cloud.netflix.zuul.web.ZuulController;
import org.springframework.cloud.netflix.zuul.web.ZuulHandlerMapping;
import org.springframework.context.ApplicationEvent;
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.netflix.zuul.filters.post;
package org.springframework.cloud.netflix.zuul.filters.route;
import javax.servlet.RequestDispatcher;
......@@ -32,12 +32,12 @@ public class SendForwardFilter extends ZuulFilter {
@Override
public String filterType() {
return "post";
return "route";
}
@Override
public int filterOrder() {
return 2000;
return 500;
}
@Override
......@@ -57,6 +57,7 @@ public class SendForwardFilter extends ZuulFilter {
ctx.set(SEND_FORWARD_FILTER_RAN, true);
if (!ctx.getResponse().isCommitted()) {
dispatcher.forward(ctx.getRequest(), ctx.getResponse());
ctx.getResponse().flushBuffer();
}
}
}
......
......@@ -25,6 +25,8 @@ import org.springframework.cloud.netflix.zuul.filters.RouteLocator;
import org.springframework.util.PatternMatchUtils;
import org.springframework.web.servlet.handler.AbstractUrlHandlerMapping;
import com.netflix.zuul.context.RequestContext;
/**
* MVC HandlerMapping that maps incoming request paths to remote services.
*
......@@ -60,6 +62,10 @@ public class ZuulHandlerMapping extends AbstractUrlHandlerMapping {
if (PatternMatchUtils.simpleMatch(ignored, urlPath)) {
return null;
}
RequestContext ctx = RequestContext.getCurrentContext();
if (ctx.containsKey("forward.to")) {
return null;
}
return super.lookupHandler(urlPath, request);
}
......
......@@ -23,6 +23,7 @@ import javax.servlet.http.HttpServletRequest;
import org.junit.After;
import org.junit.Test;
import org.springframework.cloud.netflix.zuul.filters.route.SendForwardFilter;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment