2017-12-20 2 views
0

결과 및 결과 카운트를 가져 오기 위해 별도의 API를 만들어야하는지 혼란 스럽거나 결과 API의 쿼리 문자열을 기반으로 카운트를 가져와야합니다.REST API : 결과와 결과에 대해 별도의 API를 사용해야하나요?

/api/results/ : Fetches all records 
/api/results/?city=1: Fetches all records with city=1 
/api/results/?iscount=1: Fetches the count of records i.e. list of cityId and count of record for respective cityId 
/api/results/?city=1&iscount=1: Fetch the count of record for cityId=1 

또는 쿼리 문자열 자원의 필터링에 사용되는 나에게

/api/resultcount/: Fetches the count of records i.e. list of cityId and count of record for respective cityId 
/api/resultcount/?city=1: Fetch the count of record for cityId=1 

그래서, 나는 수를 가져 오는에 대해 별도의 API를 만드는 찬성입니다. 의견?

답변

0

카운트를 가져올 다른 포인트를 만들 필요가 없습니다. 대신 응답 헤더에 카운트 세부 정보를 보낼 수 있습니다. 이 결과를 반환합니다 -

/API/결과/(방법을 GET), 다음과 같이 될 것입니다.

/api/results/(HEAD 메소드) - 응답 헤더의 결과 개수 만 반환됩니다.

아래 링크를 참조하십시오 What’s the best RESTful method to return total number of items in an object??

관련 문제