I'm currently refactoring an ASP.NetCore 2.18.0 project with a Controller which has far too many responsibilities. I actually want to divide it into 4 separate Controllers. The problem is, I don't want to burden the consumers with updating their solutions, so while I want the logic to live on the different controllers, I want to keep the routes as they currently are:
ContractListController
ContractFactoryController
ContractLinkController
ContractDocuSignController
Is there a way I can create a router which will direct Http requests to the appropriate Controller instead of using annotations on the Controller?
FWIW, I can't find MapControllerRoute
anywhere in the project. The Controller has [Route("api/v{version:apiVersion}/[controller]")] and then methods have attributes like [Route("listAll/{customerReference}")]
This was actually simpler than I expected.
My original controller class had attributes like this:
[RequireHttps]
[Authorize]
[ApiController]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]")]
public class ContractController : Controller
{
// whatever
}
All I needed to do was:
Controller
[Route("api/v{version:apiVersion}/[controller]")]
with [Route("api/v{version:apiVersion}/Contract")]