You can also provide middleware that will be applied to every job in the haystack. It will accept either an array, a closure that returns an array or an invokable class that returns an array.
This is useful if you don’t want to manually add the middleware to every job, or if the middleware cannot belong to the job on its own. One example of this being useful is if you want to apply an API rate limiter to your jobs that are making requests to a third party API.
To add middleware to every job, use the addMiddleware method when building the haystack.
If you are unfamiliar with job middleware, click here.