1、RESTful API

REST: Representational State Transfer 

url 对应服务器上的一种资源,e.g. 数据,图片等,所以url 中只含有名词,通过HTTP动词来描述对资源的操作方式。

HTTP 动词

  • GET: 获取资源
  • POST:创建或更新资源
  • PUT: 创建或更新资源
  • DELETE:删除资源
  • HEAD:获取请求报文头部,不常用
  • OPTIONS:获取信息,关于资源的哪些属性是客户端可以改变的, 不常用

2、put post区别

POST:

> modify and update a resource
POST /questions/<existing_question> HTTP/1.1

> create a resource:
POST /questions HTTP/1.1

> Note that the following is an error:
POST /questions/<new_question> HTTP/1.1


PUT:

> To overwrite an existing resource:
PUT /questions/<existing_question> HTTP/1.1

> create a resource:
PUT /questions/<new_question> HTTP/1.1

在更新资源的操作上,POST 和 PUT 基本相同。

在创建资源时,PUT可以指定资源路径,POST无法指定资源路径。

相关文章:

  • 2021-10-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2022-02-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-27
  • 2021-10-08
  • 2022-01-12
相关资源
相似解决方案