我目前正在为GET请求开发REST API。
我正在开发一个API,可以为应用程序,类别和平台返回赞助广告,例如:应用程序是谷歌,平台是移动站点,类别是主页横幅,以及基于上述输入返回广告的API。我可以为同一个应用程序提供多个类别,同一类别可以存在于任何应用程序或平台中。我不能确定如何配置URLpattern是正确的。
请告诉我一个好的URL模式。
我正在考虑以下选项。
其中category是一个字符串,例如壁纸,横幅等
根据您的描述,我对REST API的URI就是这样的
每个对象都有唯一的URI。
如果我使用REST来访问和创建特定广告,它可能看起来像
可以使用RPC而不是REST,这有时更高效/更简单,特别是如果您想要返回“已连接”数据。例如:
一切都不一定是RESTful。
我认为最好将值作为查询字符串传递,这是我们通常用搜索,过滤或排序操作做的事情。所以你不用担心订单
api/sponsored?category=1&applicationId=2&platformId=1