Global middleware is applied to all routes in your application, while per-route middleware is applied only to specific routes.
Global middleware is registered using the middlewares
option in the App
configuration, while per-route middleware is added using the middleware
decorator at the controller or action level.
Global middleware is useful for applying common functionality to all routes, such as authentication or logging. Per-route middleware allows you to apply specialized functionality to specific routes.