How to define the order of the rules in the autonomous Mule API gateway?


I have found a lot of documentation about how to set the order in which the policies are applied to a proxy using API Manager but nothing about how to change it when you are using only the API gateway standalone. Any idea?

There is a more deterministic way of making sure in which order policies are applied than depending on the order of files on the file system.

If you are using online policies (ie policies that are defined on API Manager side), then you have to define the order there. If you rename an online policy, it simply will be removed in the next polling cycle by the runtime.

If you are using offline policies (ie policies that are not defined on API Manager side, and that you have to deploy manually to the policies folder), then you can define the order in which they will be applied by defining the order attribute in the policy tag. For example:

    <?xml version="1.0" encoding="UTF-8"?>


        <mule:logger level="INFO" message="A message" />

            <api-platform-gw:api-pointcut apiName="your API name" apiVersion="your API version Name"/>

Take into account that even if you define the order, CORS and Throttling/RateLimit policies are always applied first, regardless of the order specified in those or other policies.

If two or more policies have the same order, then the runtime will decide in which order they will be applied after applying all the policies with lower order number defined.

Policies with no order specified are applied after all the policies in which order was specified are applied.

Best regards, Nahuel.