我的 API 有多个路由,例如
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{token}/{controller}/{action}",
defaults: null,
constraints: null,
handler: HttpClientFactory.CreatePipeline(
new HttpControllerDispatcher(config),
new DelegatingHandler[] { new ApiTokenValidator() })
);
config.Routes.MapHttpRoute(
name: "LoginApi",
routeTemplate: "api/{controller}/{action}",
defaults: null,
constraints: null,
handler: HttpClientFactory.CreatePipeline(
new HttpControllerDispatcher(config),
new DelegatingHandler[] { new ApiLoginHandler() })
);
如何确保我的 APIController 中的方法只能由例如 LoginApi 路由/处理程序使用?