原文链接: https://spring.io/understanding/REST

Understanding REST

REST (Representational State Transfer) was introduced and defined in 2000 by Roy Fielding in his doctoral dissertation. REST is an architectural style for designing distributed systems. It is not a standard but a set of constraints, such as being stateless, having a client/server relationship, and a uniform interface. REST is not strictly related to HTTP, but it is most commonly associated with it.

Principles of REST

  • Resources expose easily understood directory structure URIs.
  • Representations transfer JSON or XML to represent data objects and attributes.
  • Messages use HTTP methods explicitly (for example, GET, POST, PUT, and DELETE).
  • Stateless interactions store no client context on the server between requests. State dependencies limit and restrict scalability. The client holds session state.

HTTP methods

Use HTTP methods to map CRUD (create, retrieve, update, delete) operations to HTTP requests.

GET

Retrieve information. GET requests must be safe and idempotent, meaning regardless of how many times it repeats with the same parameters, the results are the same. They can have side effects, but the user doesn't expect them, so they cannot be critical to the operation of the system. Requests can also be partial or conditional.

Retrieve an address with an ID of 1:

GET /addresses/1

POST

Request that the resource at the URI do something with the provided entity. Often POST is used to create a new entity, but it can also be used to update an entity.

Create a new address:

POST /addresses

PUT

Store an entity at a URI. PUT can create a new entity or update an existing one. A PUT request is idempotent. Idempotency is the main difference between the expectations of PUT versus a POST request.

Modify the address with an ID of 1:

PUT /addresses/1

Note: PUT replaces an existing entity. If only a subset of data elements are provided, the rest will be replaced with empty or null.

PATCH

Update only the specified fields of an entity at a URI. A PATCH request is idempotent. Idempotency is the main difference between the expectations of PUT versus a POST request.

PATCH /addresses/1

DELETE

Request that a resource be removed; however, the resource does not have to be removed immediately. It could be an asynchronous or long-running request.

Delete an address with an ID of 1:

DELETE /addresses/1

HTTP status codes

Status codes indicate the result of the HTTP request.

  • 1XX - informational
  • 2XX - success
  • 3XX - redirection
  • 4XX - client error
  • 5XX - server error

Media types

The Accept and Content-Type HTTP headers can be used to describe the content being sent or requested within an HTTP request. The client may set Accept to application/json if it is requesting a response in JSON. Conversely, when sending data, setting the Content-Type to application/xml tells the client that the data being sent in the request is XML.

Understanding REST相关推荐

  1. Spatial As Deep: Spatial CNN for Traffic Scene Understanding论文翻译

    Spatial As Deep: Spatial CNN for Traffic Scene Understanding论文翻译 Abstract摘要 Convolutional neural net ...

  2. Understanding SOAP

    Understanding SOAP 转载于:https://www.cnblogs.com/daishuguang/p/4227983.html

  3. 【文本分类】BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding

    ·阅读摘要:   Bert是继Transformer之后的又一杰出的模型.Bert是一种预训练语言模型,是在GPT.Elmo.Transformer的基础上提出的.基于Bert的多个NLP领域任务都取 ...

  4. CNN交通场景解析--Spatial as Deep: Spatial CNN for Traffic Scene Understanding

    Spatial as Deep: Spatial CNN for Traffic Scene Understanding AAAI 2018 https://github.com/cardwing/C ...

  5. 人群密度估计--CSRNet: Dilated Convolutional Neural Networks for Understanding the Highly Congested Scenes

    CSRNet: Dilated Convolutional Neural Networks for Understanding the Highly Congested Scenes CVPR2018 ...

  6. 人群分析综述--Crowd Scene Understanding from Video: A Survey

    Crowd Scene Understanding from Video: A Survey ACM Trans. Multimedia Comput. Commun. Appl., Vol. 13, ...

  7. 人群行为分类数据库--Novel Dataset for Fine-grained Abnormal Behavior Understanding in Crowd

    Novel Dataset for Fine-grained Abnormal Behavior Understanding in Crowd 数据库:https://github.com/hosse ...

  8. 人群场景分析--Slicing Convolutional Neural Network for Crowd Video Understanding

    Slicing Convolutional Neural Network for Crowd Video Understanding CVPR2016 http://www.ee.cuhk.edu.h ...

  9. 人群行为分析--Understanding Pedestrian Behaviors from Stationary Crowd Groups

    Understanding Pedestrian Behaviors from Stationary Crowd Groups CVPR2015 本文主要探讨 静态人群对行人行为的影响 人群行为的建模 ...

  10. 目标检测分割--BlitzNet: A Real-Time Deep Network for Scene Understanding

    BlitzNet: A Real-Time Deep Network for Scene Understanding ICCV2017 Project: http://thoth.inrialpes. ...

最新文章

  1. 用ORBSLAM2运行TUM Dataset数据集Monocular Examples
  2. 全球及中国高速公路行业运营管理模式与经营效益分析报告2022版
  3. Swift之源码编译的环境搭建和编译流程
  4. html input file 置空,清空 HTML File Input
  5. 【算法分析与设计】矩阵链乘法最优顺序问题
  6. 加工中心宏程序生成器_数控加工中心通用铣螺纹宏程序
  7. iOS键盘遮挡输入框,输入区域自动上移
  8. ChinaJoy是什么
  9. 思杰VDI外篇XDDC安装
  10. oracle java 映射_java程序访问映射后的oracle
  11. 关于NX8.5和VS2010环境配置后,执行DLL文件,报错:未加载图像,详细信息请参见日志文件
  12. 解决DELL WIN7 bootmgr is missing
  13. windows下编译64位x264
  14. 阿里云服务器设置swap交换分区
  15. 获取指定年份的工作日和节假日后导入Excel
  16. ssm和springboot的区别
  17. 【前端面试题】01—42道常见的HTML5面试题(附答案)
  18. windows如何使用本机电脑远程桌面连接另一台电脑
  19. 2010浙大报录比及分数
  20. Chrome 便捷设置

热门文章

  1. Heap-Organized table 和 Index-Organized table 说明
  2. java-net-php-python-jspm婚恋网站计算机毕业设计程序
  3. kubectl top查看资源占用
  4. 视差动画 - 酷狗音乐引导页
  5. Pregel模型原理
  6. linux 目录挂载状态,linux肿么查看硬盘挂载状态
  7. Flutter开发 - 写一个块状带订单数量角标的个人中心页面,这个布局有点意思
  8. SCADE Suite 状态机之变量隐式赋值
  9. 软件测试提测是怎样提的,软件测试质量保障之开发提测
  10. 项目过程管理(十一)提测流程和免测标准