3

Let's have a form, where I have a couple of selects. I need to fill them with options provided from server.

But a RESTful API should only have methods for

  • Get
  • Post
  • Put
  • Delete

There's no place for retrieving some other data. I guess I should create these 4 method for each select options, but that seems to me like a overkill.

4

1 回答 1

4

您的表单数据列表可以相互正交,但您的表单显然必须将它们放在业务上下文中。您将 GET 或 PUT 或 POST 或 DELETE 的对象将是您的业务对象,它仅具有每个选择的属性。您可以单独获取填充您的选择的列表。

只有当您希望通过 REST 提供这些服务而不是直接维护它们(使用 SQL)时,您才能为每个列表使用 4 种方法。否则,只有 GET 就足够了。

于 2012-12-07T15:34:57.977 回答