Catchall Route and decision of which controllers to use
I have a catchall route in my Lumen app, and I want to decide, whether to go inside the Application after "analyzing" the route.
Example: two domains
Route 1: category/subcategory/ Route 2: category2/product.html
With my catchall Route, I call a Middleware. Inside the middleware, I get Information about the route from the database (does the given url routes to an existing category or article etc...). In our example case, it's a category with ID 233 in "route 1" and there is an article with ID 833 in route2. Now I want to go to the controller - dynamically - in the case one to CategoryController, in case 2 to ProductController. I want to inject the Information (the ID) in the controller method.
Is this generally the right way doing this? My other way was to check the validity of a route in every controller before the method is called..
Please or to participate in this conversation.