根據multiple文檔sources,可以將路由定義爲DTO上的屬性。我有以下的DTO(最後一個是在不同的文件):路由屬性被忽略
[Route("/hdos", "GET")]
public class GetHdos
{
public bool IncludeAdminUsers { get; set; }
}
[Route("/hdos/{Id}", "GET")]
public class GetHdo
{
public Guid Id { get; set; }
}
[Route("/hdos/{HdoId}/facilities", "GET")]
public class GetHdoFacilities
{
public Guid HdoId { get; set; }
}
通過以下服務一棟(最後一個是在不同的文件):
public object Get(GetHdos request)
{
return _hdos.GetAll(request.IncludeAdminUsers);
}
public object Get(GetHdo request)
{
return _hdos.GetById(request.Id)
}
public object Get(GetHdoFacilities request)
{
return _hdos.GetFacilities(request.HdoId);
}
任何調用
/hdos
/hdos/a82b955195e34bfda2fdde7da68f8992
/hdos/a82b955195e34bfda2fdde7da68f8992/facilities
返回Method not supported
。但是,如果我將它們稱爲類名稱,則路由會被擊中。有什麼我失蹤?我需要以某種方式在AppHost
中激活這些路線嗎?
在你的AppHostBase構造函數中,你是否指定程序集來查找你的服務?也不確定你的意思是通過類名稱來調用它們嗎? – kampsj 2013-05-03 13:22:27
我確實添加了服務組件。我需要添加DTO組件嗎?我的意思是如果我打電話給URL'/ gethdos'或'/ getHdo',那麼第一個或第二個服務將被分別命中。這是默認的路由約定,即DTO類名稱。 – Tyrsius 2013-05-03 15:16:28