REST简介

之前一直对REST(REpresentational State Transfer)的中文翻译(表述性状态转移)有些疑问,不明白这个表述和转移到底意味着什么,转态在这里又指什么。今天刚好看到一篇文章,现在想想其实我们的翻译就是对英文的直译,相关的词汇要放到英文的语境下意思才能凸显。文章的链接放在下面了,中间摘录几个对于represent和state和transfer的具体英文语境含义有表示的句子,以做备忘

There is plenty of nuance to consider from Roy Fielding’s original dissertation on REST, but understanding resources is critical to understanding REST. To learn what a resource is, and how it can be represented using APIs, let’s consider my own personal Facebook presence, where I am a resource. I can view an HTML representation of my resource at:

  • GET https://www.facebook.com/kinlane/

My profile is a single resource available on Facebook. I can view a representation of that resource in HTML using that URL in my web browser. I can also view another representation of it using the Facebook Graph API.

  • GET https://graph.facebook.com/v7.0/me

这句话说明REST关注的是资源,”represent “指用不同的API表示不同的资源形式

Naming, organizing, and making digital resources in this way are the seeds of REST. Now that you have your resources well-defined, you can GET these resources. More importantly, you can also manage each resource’s state over time—adding new ones, updating, transforming, and deleting existing ones. This allows for a handful of operations on each resource using HTTP methods:

  • GET: https://graph.facebook.com/v7.0/images
  • POST: https://graph.facebook.com/v7.0/images
  • PUT: https://graph.facebook.com/v7.0/images
  • DELETE: https://graph.facebook.com/v7.0/images

这段话表明REST关注于以特定的命名形式组织以及使数字资源在互联网上可用,同时资源的状态(“state”,即增删改)也可以随着时间进行转变(“transfer”)

参考链接:

https://blog.postman.com/rest-api-definition/

posted @ 2020-09-11 18:55  MarshWinter  阅读(204)  评论(0编辑  收藏  举报