這是一個簡單的問題,管理跨asp.net web api項目的許多方法。用webapi管理api服務中的許多方法路由
我們有相當多的方法是這樣的:
ProductsApiController.GetByType(string type, string x)
ProductsApiController.GetByType(string type, int limit)
//method has a number of arguments..
ReportsApiController.GetAll(string x, string y)
的問題:我們有一噸的自定義參數的方法,我們必須定義爲他們每個人的
一個 定製路線routes.MapRoute(
name: "ProductRoute",
url: "ProductsApiController/{type}/{x}"
);
routes.MapRoute(
name: "ReportRoute",
url: "ReportsApiController/{x}/{y}"
);
我正在簡化簽名,有很多參數的方法很多,這些方法通常不會有參數。
這是什麼一般的模式?有沒有更好的方法來做到這一點,或者我只有離開這個。
謝謝。這正是我需要的:) – pradeep