How should I implement x-api-key and api rate limit in CodeIgniter 4 ? |
Hi
I have a bunch of ResourceController controllers which build a simple api rest Then I have a filter with this before code (which is assigned only to api routes) Code: Services::response()->setHeader('Access-Control-Allow-Origin',$base_url); I have to implement for all the api controllers, the following 1. X-API-KEY 2. API rate limit (fixed for all routes, very basic) Which would be the best way to implement each? Create a new filter for each feature? Does anyone have any useful links to share to get started? Thanks a lot
Enrique
https://beza.com.ar
New filter for each feature.
This will make unit testing easier. And it will reduce the chance of breaking everything by changing some part of the code.
Rate Limiting sample code:
https://codeigniter4.github.io/CodeIgnit...e-limiting |
Welcome Guest, Not a member yet? Register Sign In |