The types of plugins
There are two types of plugins that can be scripted with Tyk:
Middleware components – these execute either
PREmiddleware component will execute before any session validation or token validation has taken place, while a
POSTmiddleware component will execute after the request has been passed through all checks and is ready to be proxied upstream
Dynamic event handlers – these components fire on certain API events (see the event handlers section), these are fired Async and do not have a cooldown timer.
Middleware components receive extra data (depending on their context), but all have the capability to modify the request and the session object if it has been made available to the plugin. Usage of the Session object in a middleware component is expensive as the object needs to be retrieved, and de/re-encoded multiple times as it passes through the system.