Does anyone have any pointers on ways to implement the following:
I'm looking for an efficient way to map multiple routes to two main controllers while still being able to get part of that route from the matched controller. Example:
/v1/api/[type-of-record]
would get matched to an ApiController and Get action. That's fine, but I need to be able to get the type-of-record
while in that action. I've tried setting the name on each route as part of a micro collection (as the third parameter - but that only works for GET bindings).
The type-of-record
is set by the database so I cannot create a controller for each. The best way I've found is use a catch-all e.g. /v1/api/{record-type:[a-zA-Z\-]+}
and then using the before event to 404 or redirect if that record type isn't allowed.
There must be a better way to do this though. Any thoughts?