try rewirte of all backoffice controllers to ApiControllers

This commit is contained in:
2020-10-27 15:47:23 +01:00
parent edfb6ec2e5
commit 6eb81a5eeb
37 changed files with 315 additions and 354 deletions
@@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
using System;
namespace zero.Web.Controllers
{
public class ZeroBackofficeControllerModelConvention : IControllerModelConvention
{
readonly AttributeRouteModel RouteModel;
readonly Type BaseClass = typeof(BackofficeController);
public ZeroBackofficeControllerModelConvention(string backofficePath)
{
RouteModel = new AttributeRouteModel(new RouteAttribute(backofficePath + "/api/[controller]/[action]"));
}
public void Apply(ControllerModel controller)
{
if (!controller.ControllerType.IsSubclassOf(BaseClass))
{
return;
}
foreach (var selector in controller.Selectors)
{
selector.AttributeRouteModel = RouteModel;
}
}
}
}