Introducing Proxy Rules
Now that Maque 1.1 is out in the wild we will start writing a series of posts that explore what is new in 1.1, and there is a lot!! Some of the changes are small, subtle improvements to make Maque easier to use and some of the changes are massive, like the newest Rule type: Proxy Rules.
Why did we create Proxy Rules?
For a lot of our development projects, a remote service already exists that returns the data we need in our application. To integrate Maque into our workflow, we need to create a new Data Services that mocks up the existing service. Before 1.1, this meant creating a Rule, and then capturing (or re-creating) the data being returned by the remote service. Once we had that data, we would save it on disk and let the Maque Rule return it. This was kind of a pain, but usually worth the effort.
So far so good, but as the project grows and becomes more complex, the data from the remote service may change. Ok, 9 out of 10 times it would change if this is a new project. This means, recapturing the data and updating our rules each time a change is made. Even more pain!!
Worst case, the service uses custom headers and our app requires these details. If this was true, then uh-oh, Maque wasn't so friendly anymore. At DevelomentArc, we use Maque all the time and we hit this header wall on a few projects. There isn't anything more frustrating when your own tool doesn't do what you need. We needed a better way of handling data for existing services, so we created Proxy Rules!
Ok, that makes sense, but what are Proxy Rules
To solve the issues outlined above, and enable some other cool features we will talk about later, we created Proxy Rules. A Proxy Rule is a new Rule type that forwards incoming requests from Maque to another server and then returns the server response back to the requester. Maque will then cache the response from the other server and the next time the Rule is triggered, Maque returns the cached response and the remote server is now out of the loop.
This makes creating complex results so much easier! Also, if the service changes or the data changes, you can clear the cache and have Maque update the response on the next request. To make things even easier, we store all the header information so the returned result is 100% exactly the same. Well, 99% the same, we update the timestamp, you know, 'cause we should' and we also enable Cross-Origin (CORS), just to make your life easier.
The only difference between a Proxy Rule and a Standard Rule (aka just a Rule in version 1.0.x) is how the return data is handled. A Standard Rule would return a file that you created or previously had on your machine and allowed you to define the return type. A Proxy Rule will generate its data and return type from either the direct response of a remote URL or the previously cached response. Outside of that, Rules are Rules. You still define arguments, delays, enable them, disable them, make them default or errors, it's all up to you.
Live long and Proxy!
For all the gory details, check out our Proxy Rule documentation. We break down all the ways you can use them and how the cache works. Make sure to download Maque 1.1 and we will talk about the Incoming Request Capture Wizard next time!
~ The Maque Team ~









