与 REST 协商活动和非活动产品列表的内容

Content negotiation with REST for list of active and inactive products

我有两个页面,一个显示活动产品列表,另一个不活动并且使用相同的端点来显示产品。

在数据库中,产品 table 有一个字段 active = 1 or 0,区分这两种请求的标准 REST 样式约定是什么。

GET /products(有效产品列表)

GET /products(非活动产品列表)

您可以在请求中提供 'active' 标志作为参数。

 # this returns the list of active products
 GET /products?active=1

 # this returns the list of inactive products
 GET /products?active=0

您的服务器实现可以提取活动参数的值并做出相应响应。