Closed ericel closed 8 months ago
@ericel The registerFilter method is suitable for filters that cannot be created automatically, for example if their constructor has some parameters. The method register the filter to the reflection system in drogon, make it can be used as normal filters. If you need global filters, please use the GlobalFilters plugin.
@an-tao Thanks a lot.
I think it would make sense to have the ability to set global filters in the form of middleware. Drogon App has the registerFilter() method, but truth be told, it is of no use. At least I haven't found it to be useful because filters registered with that method are never called.
Web development requires middleware that sometimes would make sense to apply site-wide. Setting such filters on each route definition doesn't make much sense.
for example:
But this filter is never called when declared like it is except on individual routes.