Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Dynamic Module Route Middleware #763
I have a project where I have a module with the name "Scanner" that has an Ajax route that will scan a page.
The Ajax route is like this.
This "Scanner" Module is used by two other modules and let's say for example it's a "Magazines" Module and a "Books" Module.
Users that have access to the "Magazines" Module will have the permission to scan a page from a magazine and users that have access to the "Books" Module will have the permission to scan a page from a Book.
Both modules will call the same "Scanner" Module Ajax route above to scan a page. My code already knows whether the request came from the Magazine or the Book module but what I cannot figure out is how to dynamically add the permission middleware on the Ajax route without hard coding it on the Scan Module routes as on the example above.
If I later on add a new module for example "Newspaper" Module that will scan a page from a newspaper I will have to remember to add the "newspaper.can.scan.page" permission on the Ajax route.
Is there any way to achieve what I am asking?