Remedy Plugins
Remedy plugins make up for a significant part of Lunar's magic: they allow users to solve API consumption problems with a few lines of configuration.
How It Works
A remedy policy can be defined globally, or on a per-endpoint basis. When a new request arrives at Lunar, it first goes through the process of finding and applying relevant remedy policies. The result of this step might:
- yield a Lunar-generated response, in which case the original API provider will not be called, or
- modify the request/response before it goes out to the original API provider or right after it returns from it, or
- do nothing, and simply forward the call to the original API provider
Similarly to requests, all responses pass through that engine before being returned back to callers. This is key in order for Lunar to work properly. Take the Response-Based Throttling remedy plugin for example: it needs to cache the initial throttled response in order to work properly.
Identifying Responses Generated by Lunar
In case Lunar generated the response for a certain transaction, the x-lunar-generated: true
header will be added to that response.
Remedy Chaining
In case more than one remedy policy was found, the result of their application will be combined. Read more about remedy chaining here.