C# ServiceStack Rest-复杂uri层次结构
我正在使用c框架“servicestack”创建rest Web服务http://www.servicestack.net/ 我在试图找出如何支持更复杂的rest层次结构时遇到了一些问题 我正在配置各种路由,它工作得非常好C# ServiceStack Rest-复杂uri层次结构,c#,rest,
servicestack,C#,Rest,
servicestack,我正在使用c框架“servicestack”创建rest Web服务http://www.servicestack.net/ 我在试图找出如何支持更复杂的rest层次结构时遇到了一些问题 我正在配置各种路由,它工作得非常好 Routes .Add<MerchantDto>("/merchants") .Add<MerchantDto>("/merchants/{id}") .Add<MerchantDto>("/merchantGrou
Routes
.Add<MerchantDto>("/merchants")
.Add<MerchantDto>("/merchants/{id}")
.Add<MerchantDto>("/merchantGroups/{merchantGroupId}/merchants")
.Add<MerchantDto>("/merchantGroups/{merchantGroupId}/merchants/{id}")
.Add<StoreDto>("/stores")
.Add<StoreDto>("/stores/{id}")
.Add<StoreDto>("/merchants/{merchantId}/stores")
.Add<StoreDto>("/merchants/{merchantId}/stores/{id}");
这一切都很好。这个问题就是这样做
.Add<StoreDto>("/merchantGroups/{merchantGroupId}/merchants/{merchantId}/stores/{id}
这里的问题是StoreDto对象只包含一个MerchantId,而不包含MerchantGroupId,因此这不起作用
一种解决方案是将MerchantGroupId添加到DTO中,但问题是我正在与其他WCF服务共享DTO,如果我在StoreDto中具有MerchantGroupId属性,而在检索操作期间从未填充该属性,则可能会造成混淆
另外,我认为这是在不同的地方出现的,所以我希望有一个更好的方法来做到这一点
有什么建议吗?Like@mystry说,我只是试图生成类似MVC的url路径,让事情变得复杂
我坚持按原样使用uri路径 为什么要使用包含客户端没有的信息的Url?现在还不清楚你的目标是什么。我在想如果整个事情都进展顺利会更好?因此,您可以通过/merchantGroups/merchant url获得商家,并继续在该“url路径”上获得店铺。客户无法弥补这一点,您要么给它merchengGroupId,要么给它应该发布到的url。