Web服务 – RESTful API是否过度使用误用?

Web服务 – RESTful API是否过度使用误用?,第1张

概述我只花了一整天阅读 Fielding’s famous dissertation on REST.它在 Conclusion部分说: REST, a novel architectural style for distributed hypermedia systems. … Although Web-based applications can include access to other s 我只花了一整天阅读 Fielding’s famous dissertation on REST.它在 Conclusion部分说:

REST,a novel architectural style for distributed hypermedia systems.

Although Web-based applications can include access to other styles of
interaction,the central focus of its protocol and performance
concerns is distributed hypermedia. REST elaborates only those
portions of the architecture that are consIDered essential for
Internet-scale distributed hypermedia interaction.

并根据Wikipedia:

Hypermedia,an extension of the term hypertext,is a nonlinear medium
of information which includes graphics,audio,vIDeo,plain text and
hyperlinks.

所以在我看来,REST有点适用于基于Web的内容密集型系统.但很明显,RESTful API几乎是所有关于Web服务的流行语.

那么这种过度使用了吗?还是误用

参考文献:

RESTful APIs,the big lie.

What exactly is RESTful programming?

What does “hypermedia data formats” mean in Fielding’s famous dissertation when talking about Cookies

解决方法 我认为JsON不是媒体而是文字或视频.所以从本质上讲,JsON中表示的序列化对象是一种媒介.

现在,“超媒体”是在语义上链接在一起的媒体.您可以通过包含链接:HAL或HATEAOS来制作JsON超媒体.

在此,您将相关资源的链接添加到JsON文档. Example:

{    "content": [ {        "price": 499.00,"description": "Apple tablet device","name": "iPad","links": [ {            "rel": "self","href": "http://localhost:8080/product/1"        } ],"attributes": {            "connector": "socket"        }    },{        "price": 49.00,"description": "Dock for iPhone/iPad","name": "Dock","href": "http://localhost:8080/product/3"        } ],"attributes": {            "connector": "plug"        }    } ],"links": [ {        "rel": "product.search","href": "http://localhost:8080/product/search"    } ]}

人们争辩说,没有链接,JsON不是超媒体.

我也不想尝试将每个API都塞进REST中.并非每个API都与资源有关,因此如果您的API代表RPC,请将其称为RPC:RPC API.

总结

以上是内存溢出为你收集整理的Web服务 – RESTful API是否过度使用/误用?全部内容,希望文章能够帮你解决Web服务 – RESTful API是否过度使用/误用?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1070408.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存