gpt4 book ai didi

休息 API : Should we have separate API for result and result count?

转载 作者:行者123 更新时间:2023-12-05 05:18:25 25 4
gpt4 key购买 nike

我很困惑我们是否应该创建单独的 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 来获取计数。意见?

最佳答案

我们不需要创建另一个点来获取计数。相反,我们可以在响应 header 中发送计数详细信息。

它会像下面这样,

/api/results/(GET 方法) - 这将返回结果。

/api/results/(HEAD method) - 这只会在响应 header 中返回结果计数。

下面请看link

关于休息 API : Should we have separate API for result and result count?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47906473/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com