예, 동일한 웹 서비스를 가리키는 여러 개의 REST-ful 경로를 가질 수 있습니다.
당신이, 당신은 HttpRequest를 통해 서비스를 호출하는 데 사용되는 요청 경로를 검사 할 수있는 그대로의 경로를 마칠 경우 예 :
var httpReq = base.RequestContext.Get<IHttpRequest>();
httpReq.PathInfo //or httpReq.RawUrl, httpReq.AbsoluteUri, etc.
그것이 요청의 어떤 종류의 당신이 운동하는 방법, 채워진 요청 DTO보고있다 -하지만 인기 /최근/ 및 //를 구분하는 다른 요청 DTO 속성에 저장하고 그 값이 즉 검사해야
[RestService("/items/{Type}")]
[RestService("/items/{Type}/{Page}")]
public class Items
{
public string Type { get; set; }
public int? Page { get; set; }
}
public class ItemsService : ServiceBase<Items>
{
public override object Run(Items request)
{
if (request.Type == "recent")
if (!request.Page.HasValue)
//path 1
else
//path 2
else if (request.Type == "popular")
if (!request.Page.HasValue)
//path 3
else
//path 4
}
}
이것은 StackOverflow 질문과 비슷합니다. Need help on servicestack implementation
멋진! 네가 좋은 대답을 할 줄 알았어. 그건 그렇고,이 내 서비스는 훌륭하게 잘 진행되고 있습니다! RedisStackOverflow 예제는 매우 유사하므로이 예제를 사용하지 마십시오. 사랑의 ServiceStack! – robertmiles3
@ robertmiles3 굉장하고, 듣기 좋게 생각합니다 :) IMO Redis 기반의 ServiceStack 앱은 멋진 UX를 만들어 낼 것입니다. 끝나면 앱 링크를 Google 그룹에 게시하는 것을 잊지 마십시오! – mythz