官术网_书友最值得收藏!

Representational State Transfer

Representational state transfer (REST) is an architectural style for resource-oriented services. It is used by most web applications today to standardize communication between the client and the server. If HTTP was the spoken language, REST would be a set of rules for that language.

REST-based web services, also known as RESTful APIs, have a few constraints they need to follow:

  • Consistent interface: Every entity is a resource that will have a unique endpoint— a unique base URL. All operations on a resource will be available via that URL.
  • URL and HTTP methods: When a resource URL is combined with an HTTP method, it describes an operation performed on the resource. For example, GET means retrieving data, POST means creating data, and DELETE means deleting data.
  • Statelessness: Just like the HTTP protocol, RESTful services are stateless. This means that each request is independent and information regarding previous requests is never used.
  • Cacheable: For each response, the server defines whether it is cacheable or not. Once a response is set as cacheable, the client caches it and uses the data from the cache instead of requesting it from the server again and again.

For example, in an application that manages students, we could have the following services:

REST has become the de facto style of communication between the backend and the frontend. This is especially because it is a simple concept, yet very powerful — it makes the backend understandable to other developers and simple to modify and scale, and supports multiple types of clients, including web and mobile.

主站蜘蛛池模板: 南江县| 独山县| 桑日县| 台中市| 哈尔滨市| 格尔木市| 东乌珠穆沁旗| 洛隆县| 丹棱县| 资兴市| 广昌县| 太原市| 黑水县| 樟树市| 民丰县| 阿鲁科尔沁旗| 原阳县| 宜良县| 罗田县| 阜平县| 中方县| 河西区| 昔阳县| 将乐县| 剑川县| 黄大仙区| 馆陶县| 阜康市| 磴口县| 枣强县| 板桥市| 博罗县| 宝清县| 绥滨县| 金塔县| 天峨县| 襄城县| 尼木县| 潮州市| 长丰县| 毕节市|