gpt4 book ai didi

http - http中GET,PUT,DELETE,POST方法的实际使用

转载 作者:可可西里 更新时间:2023-11-01 16:56:13 25 4
gpt4 key购买 nike

我正在使用 asp.net web API(RESTful 服务),我可以通过提供一些额外的参数使用 post 方法进行删除、插入和更新操作。它是否仅用于可以区分功能的单词的语义用法?。

我发现不错的 SO post Here .有如下疑问

  1. 我可以使用 POST 发布数据,那为什么要 PUT
  2. 我可以通过传递已删除的 id 通过 POST 进行删除,那为什么 DELETE
  3. 当服务器端收到每个头方法时会发生什么。

请提供帮助。谢谢..

最佳答案

REST 架构的架构属性之一是“接口(interface)的简单性”。 GET、POST、PUT 等是众所周知的 HTTP 动词,它们在早期也可用。 REST 只定义了如何使用这些来实现 RESTFUL 实现。如果你遵循它们,那么你就是在做 RESTful 实现,如果不这样做......你正在做一些只有你自己知道的事情。

您也可以使用 GET 来删除记录(只需在查询字符串中提供 ID 并编写底层实现来删除 QS 中提供的任何 ID)但是您梦想世界之外的人怎么会知道如果我使用 GET 执行此操作,记录将被删除。

REST 架构为所有动词分配了一个目的,以便每个人都知道将要发生什么。如果您不遵循它们,那么您正在创造不符合标准的东西。

如果按照 REST 的定义(来自 wiki):

Representational state transfer (REST) is a software architectural style consisting of a coordinated set of architectural constraints applied to components, connectors, and data elements, within a distributed hypermedia system. REST ignores the details of component implementation and protocol syntax in order to focus on the roles of components, the constraints upon their interaction with other components, and their interpretation of significant data elements.

关于http - http中GET,PUT,DELETE,POST方法的实际使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23777714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com