【问题标题】:REST API Endpoint Design: Meta-Data change vs subelement insertREST API 端点设计:元数据更改与子元素插入
【发布时间】:2016-06-13 23:38:25
【问题描述】:

我们正在讨论如何构建我们的宁静 API 设计的下一个演进。我们有以下问题。想一想将返回具有某些元素的播放列表的资源。每个播放列表都有一个永不改变的 id。起初,这看起来很简单。

POST /playlists => create a new playlist, id will be returned
GET /playlists/id => retunrs the playlist contents
POST /playlists/id => insert an element to the playlist
DELETE /playlists/id => delete the whole playlist

接下来我们要做的就是播放列表都有一些元数据。例如。一个名字。现在如何将元数据更改为POST /playlists/id

对此有何最佳实践建议?

【问题讨论】:

  • 你问是否可以同时使用 POST /playlists/id 和 POST /playlists/name ?
  • 没有。对不起,如果问题不是那么清楚。问题是我们正在有效地管理播放列表端点上的不同事物。子项和元数据查询端点 qith GET 时,应返回两者的组合。发布到它时,我们需要分开更新元数据和添加项目的方式。

标签: api rest architecture


【解决方案1】:

老问题,我知道,但您想 PUT(或 PATCH)到 /playlists/id 以更新播放列表本身。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-22
    • 2022-12-11
    • 1970-01-01
    • 1970-01-01
    • 2017-05-19
    • 2018-03-11
    相关资源
    最近更新 更多