Add MetaFilter.serveRegex(Pattern)
This allows the use of precompiled patterns, such as those compiled with flags. Change-Id: I1c87fea98e246004aecbae3aabaf1d21fbf3176e
This commit is contained in:
parent
61c4e39067
commit
b12f80e71c
|
@ -52,6 +52,7 @@
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
|
@ -116,6 +117,17 @@ public ServletBinder serveRegex(String expression) {
|
|||
return register(new RegexPipeline.Binder(expression));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a binding for a regular expression.
|
||||
*
|
||||
* @param pattern
|
||||
* the regular expression to pattern match the URL against.
|
||||
* @return binder for the passed expression.
|
||||
*/
|
||||
public ServletBinder serveRegex(Pattern pattern) {
|
||||
return register(new RegexPipeline.Binder(pattern));
|
||||
}
|
||||
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
servletContext = filterConfig.getServletContext();
|
||||
}
|
||||
|
|
|
@ -91,6 +91,10 @@ static class Binder extends ServletBinderImpl {
|
|||
pattern = Pattern.compile(p);
|
||||
}
|
||||
|
||||
Binder(final Pattern p) {
|
||||
pattern = p;
|
||||
}
|
||||
|
||||
UrlPipeline create() {
|
||||
return new RegexPipeline(pattern, getFilters(), getServlet());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue