App*_* S. 4 api rest uri hyperlink
在REST中,它完全与链接有关.基本上,API用户只需要一个链接,即顶级链接.这通常是http:// server/api /或类似的东西.浏览层次结构时会发现所有其他链接.例如,GET / api /可能会为您提供指向/ api/users /和/ api/images /和/ api/users /的链接,可能会为您提供指向/ api/users/john /的链接,依此类推.
那就是说,我想知道是否有某种标准如何格式化这些链接.毕竟,如果全部是关于链接,爬虫应该能够从顶部开始发现系统中的所有资源?
我做了一些研究.XML媒体类型,找不到任何标注的标准.我们选择/ users / resource.有人写
<users>
<user name='john' uri='/users/john'/>
<user name='steve' uri='/users/steve'/>
</users>
Run Code Online (Sandbox Code Playgroud)
其他人写
<users>
<user name='john' link='/users/john'/>
<user name='steve' link='/users/steve'/>
</users>
Run Code Online (Sandbox Code Playgroud)
其他人使用xlink,例如:
<users>
<user name='john' xlink:href='/users/john'/>
<user name='steve' xlink:href='/users/steve'/>
</users>
Run Code Online (Sandbox Code Playgroud)
等等.
我可能在这里无知,但是不应该有某种标准规定如何格式化到其他资源的链接,所以没有任何关于如何格式化数据的知识?换句话说,应用程序A1的API的爬虫X可能不适用于应用程序A2的API,因为A1将其链接格式设置为与A2不同.
在上面,我只讨论XML媒体类型.当您使用JSON时,该领域还有更多版本.
为什么REST没有指定如何格式化资源相关资源的链接?
| 归档时间: |
|
| 查看次数: |
779 次 |
| 最近记录: |