Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2015-03-06 00:29:54 -0500
committerGreg Wilkins2015-03-06 00:29:54 -0500
commita6a71e4705c6455327da0e5d22b828d85c7166eb (patch)
tree55206a1a0a55431eef0916902b139b69af397091 /jetty-rewrite
parent6ed01cf15b95a51253677de791bdbf2cab650015 (diff)
downloadorg.eclipse.jetty.project-a6a71e4705c6455327da0e5d22b828d85c7166eb.tar.gz
org.eclipse.jetty.project-a6a71e4705c6455327da0e5d22b828d85c7166eb.tar.xz
org.eclipse.jetty.project-a6a71e4705c6455327da0e5d22b828d85c7166eb.zip
458140 Added DispatcherType support to RewriteHandler
Diffstat (limited to 'jetty-rewrite')
-rw-r--r--jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java29
1 files changed, 26 insertions, 3 deletions
diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java
index b124524571..495aea7303 100644
--- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java
+++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java
@@ -19,7 +19,10 @@
package org.eclipse.jetty.rewrite.handler;
import java.io.IOException;
+import java.util.Arrays;
+import java.util.EnumSet;
+import javax.servlet.DispatcherType;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -170,8 +173,8 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
*/
public class RewriteHandler extends HandlerWrapper
{
-
private RuleContainer _rules;
+ private EnumSet<DispatcherType> _dispatchTypes = EnumSet.of(DispatcherType.REQUEST);
/* ------------------------------------------------------------ */
public RewriteHandler()
@@ -292,6 +295,23 @@ public class RewriteHandler extends HandlerWrapper
_rules.setOriginalPathAttribute(originalPathAttribute);
}
+ /* ------------------------------------------------------------ */
+ public EnumSet<DispatcherType> getDispatcherTypes()
+ {
+ return _dispatchTypes;
+ }
+
+ /* ------------------------------------------------------------ */
+ public void setDispatcherTypes(EnumSet<DispatcherType> types)
+ {
+ _dispatchTypes=EnumSet.copyOf(types);
+ }
+
+ /* ------------------------------------------------------------ */
+ public void setDispatcherTypes(DispatcherType... types)
+ {
+ _dispatchTypes=EnumSet.copyOf(Arrays.asList(types));
+ }
/* ------------------------------------------------------------ */
/* (non-Javadoc)
@@ -302,8 +322,11 @@ public class RewriteHandler extends HandlerWrapper
{
if (isStarted())
{
- String returned = _rules.matchAndApply(target, request, response);
- target = (returned == null) ? target : returned;
+ if (_dispatchTypes.contains(baseRequest.getDispatcherType()))
+ {
+ String returned = _rules.matchAndApply(target, request, response);
+ target = (returned == null) ? target : returned;
+ }
if (!baseRequest.isHandled())
super.handle(target, baseRequest, request, response);

Back to the top