Directory 'Framework/Middleware' hosts Framework Middleware: Main and Addons.
Directory 'Application/Instance/Middleware' hosts custom Middleware.
Middleware for each route is declared in route files
i.e. Application/Routes/GETRoutes.php and Application/Routes/POSTRoutes.php.
Use parameter $middleware of method $routes->add(...) in order to declare the Middleware for each route.
$routes->add(
'/',
HomeController::class,
'index',
// $middleware
[
AAAInit::class,
ApplicationStatusJWT::class,
UserDetails::class,
HttpCaching::class => ['interval' => 3600],
CSP::class,
SEO::class,
],
[
'changefreq' => 'daily',
'priority' => 0.9,
]
);
Irrespective of the order set in route files, all framework middleware classes will run in a certain order.
Class Framework\Framework\Libraries\Routes\MiddlewareHandler
will enforce this order.
- AAAInit::class
- Admin::class
- ApplicationStatusJWT::class
- CaptchaEnd::class
- CSP::class
- CSRFEnd::class
- HttpCaching::class
- SEO::class
- Throttle::class
- UserDetails::class
Nothing at the moment.
All Middleware must implement Framework\Framework\Middleware\MiddlewareInterface
.
Framework middleware runs before any custom/user-defined middleware on both before and after stages.