Yet another API template for the InterSystems IRIS Data platform

Added simple implementation of rate limits. Now, you can set up the maximum amount of requests per minute for your APIs. Just set the value by the route key in the lookup table RESTRateLimits, similar RESTRoutes table. Also, you can use a wildcard (*) as a method name: Sample.API:*
Tip: If you need a more flexible and enterprise solution, I advise you to look at API Manager
Features out-of-the-box:
- Adds online OpenAPI 2.0 specification (see /swaggerendpoint) to your APIs
- Adds /healthcheckendpoint - a simple way to check API publication
- Metrics in OpenMetrics format are included
- Rate limits (requests per minute) can be set
- And main: adds to all your API common entry point in Interoperability (Production). That, in turn, allows you to use the best IRIS feature - visual traces! 🔥
- Implement the needed API using a specification-first way
- Add to your .dispclass routes/swaggerand/healthcheck(seeSample.API.dispfor example)
- Add calls REST.Service.APIto your.implclass (see example inSample.API.impl)
Quit ##class(REST.Service.API).Call(body, $$$CurrentMethod, $CLASSNAME())
- Add to Production REST.Service.APIservice
- Create and add to Production handlers for the methods of your custom API. Set REST.Process.CallHandleras the parent class if you need correct links building in Production UI. You can find a sample of handler in theSample.Process.TestPostclass
- Add routes for API methods to the RESTRouteslookup table (sampleRESTRoutes.LUT)
- Enjoy! 😎
All metrics are provided in OpenMetrics format. So, you can grab it with Prometheus and visualize it in Grafana. Details about setting up monitoring in the IRIS can be found here. Don't forget to check the roles of api/monitor application and to enable custom sensors in the IRIS terminal:
zn "%SYS"
d ##class(SYS.Monitor.SAM.Config).AddApplicationClass("REST.Core.Monitor", "YOUR_NAMESPACE")