<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Additionally, I think you will have to
standardize on:<br>
a) operators - words (or you support symbols also). [a and b] vs
[a && b]<br>
b) order of processing. (Mis-configuration may have side effects)<br>
<br>
On 05/12/2013 07:17 PM, Stuart Douglas wrote:<br>
</div>
<blockquote
cite="mid:CAAoo=c6EjjgWHgW=ap=5o-zTFQtw+38GcXfg9nu_yhFOpF8iRQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>
<div>A fairly common requirement for web requests is to
enable or disable a certain action based on the state of
the request. e.g:<br>
- disable compression if the response > 10Mb<br>
- If the user agent is X add header Y<br>
- If the path starts with /private disable caching<br>
etc<br>
<br>
To enable us to acomplish this Undertow has the concept of
predicates[1], which as you would expect are a function
object that takes the exchange as an argument and returns
a boolean value. <br>
<br>
We also provide boolean operator predicates (and, or, not)
that allow you to combine these predicates into
arbitrarily complex values. The idea is that if a user
want to configure a conditional action on the request they
will use these predicates to specify the condition. <br>
<br>
To that end we need some way of representing them in the
Wildfly configuration file, and so I have hacked up a
basic syntax to configure them, and I would like some
feedback. The configuration syntax will written directly
into the standalone.xm and jboss-web.xmll to conditionally
enable handlers. <br>
<br>
A basic example looks like:<br>
<br>
path["/MyPath"] or (method[value="POST"] and not
requestHeadersPresent[value={Content-Type,
"Content-Encoding"}, ignoreTrailer=true] )
<br>
<br>
The following boolean operators are built in, listed in
order or
precedence:
<br>
-
not
<br>
-
and
<br>
- or <br>
<br>
They work pretty much as you would expect them to. All
other tokens are
taken
<br>
to be predicate names. If the predicate does not require
any parameters then
the
<br>
brackets can be omitted, otherwise they are
mandatory.
<br>
<br>
If a predicate is only being passed a single parameter
then the parameter name can be
omitted. <br>
Strings can be enclosed in optional quotations marks, and
quotation marks can be escaped using
\"
<br>
<br>
Array types are represented via a comma separated list of
values enclosed in curly braces.<br>
<br>
</div>
Predicate definitions themselves are loaded via a service
loader mechanim, with the service implementation specifying
the name and the parameter types. <br>
</div>
<br>
</div>
I would be interested to hear what people think. At the moment
this is very simple, however a by product of this simplicity is
that you need multiple predicates to handle similar things (e.g.
requestHeadersPresent, responseHeadersPresent,
requestHeaderContains, requestHeaderEquals etc).<br>
<div>
<div>
<div><br>
[1] <a moz-do-not-send="true"
href="https://github.com/undertow-io/undertow/tree/master/core/src/main/java/io/undertow/predicate">https://github.com/undertow-io/undertow/tree/master/core/src/main/java/io/undertow/predicate</a><br>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
</blockquote>
</body>
</html>