Middleware is applied to routers twice. This is because we are applying middleware when pluvo.enable, router.enable, and router.add_route are called. So instead of applying middleware in the request handler, we are only needing to apply the middleware during setup, which helps simplify the actual request handling.
Also, the middleware should be applied to the route not found handler so that if a route isn't found, middleware can still occur (such as logging or static handling).
Description
Middleware is applied to routers twice. This is because we are applying middleware when
pluvo.enable
,router.enable
, androuter.add_route
are called. So instead of applying middleware in the request handler, we are only needing to apply the middleware during setup, which helps simplify the actual request handling.Also, the middleware should be applied to the route not found handler so that if a route isn't found, middleware can still occur (such as logging or static handling).