Hello Sean
It is a bit tricky to exclude a path ( I am assuming you want to do this in
some specific scenario ). There are few options I can think of:
Option 1. You can try to make the rules more specific so it can apply only
to the URLs we want, the downside is, since we are narrowing the rule there
is a high chance of other path failures.
Option 2. Create an exact rule for the patch you want to exclude and make
the rule empty or just rewrite the existing path, make sure you add the
corresponding patch to service.xml file.
Option 3. Use the flow=AND and flow=OR conditions with option 2. This is
not ideal for excluding a path but it could be a better option.
e.g.
<rule name="test-rule-with-complex-flow" flow="OR">
<!-- Path to exclude -->
<match pattern="*://*:*/~/{path=**}?{**}">
<!-- Here we can keep the URL unchanged -->
<rewrite
template="test-scheme-output://test-host-output:777/test-path-output/test-home/~{path=**}?{**}"/>
</match>
<match pattern="*://*:*/{path=**}?{**}">
<rewrite
template="test-scheme-output://test-host-output:42/test-path-output/{path}?{**}"/>
</match>
</rule>
Where
OR = At least one condition proceeding a set of one or more actions must
succeed for the actions to be executed.
AND = All conditions proceeding a set of one or more actions must succeed
for the actions to be executed.
Best,
Sandeep
On Fri, Jun 15, 2018 at 10:08 AM Sean Roberts <[email protected]>
wrote:
> Knox experts – How would a path be excluded from a route or filter within
> a Knox service?
>
>
>
> For example, in the ‘ambari’ service the filter below converts
> “text/plain” content to “application/json”.
>
>
>
> Many paths needs to be excluded from that conversion.
>
>
>
> service.xml
> <https://github.com/apache/knox/blob/master/gateway-service-definitions/src/main/resources/services/ambari/2.2.0/service.xml#L24-L28>
> :
>
> <route path="/ambari/api/v1/**">
>
> <rewrite apply="AMBARI/ambari/api/outbound" to="response.body"
> />
>
> <rewrite apply="AMBARI/ambari/api/inbound" to="request.body"/>
>
> </route>
>
>
>
> rewrite.xml
> <https://github.com/apache/knox/blob/master/gateway-service-definitions/src/main/resources/services/ambari/2.2.0/rewrite.xml#L29-L33>
> :
>
> <filter name="AMBARI/ambari/api/outbound">
>
> <content type="text/plain" asType="application/json">
>
> <apply path="$.**.href" rule="AMBARI/ambari/href/outbound"/>
>
> <apply path="$.**.context_path" rule=
> "AMBARI/ambari/context_path/outbound"/>
>
> </content>
>
>
>
> --
>
> Sean Roberts
>