基于REST API中发现什么是 [英] What is discovery based in Rest API

查看:153
本文介绍了基于REST API中发现什么是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是基于发现REST API?

What is a discovery based REST API?

从我可以从这个参考 https://en.wikipedia.org/wiki/HATEOAS <明白/ A>基于发现的REST API总是给一个链接到响应在未来可能采取的行动或行动。

From what i can understand from this reference https://en.wikipedia.org/wiki/HATEOAS a discovery based REST API always give a link to the next possible action or actions within the response.

正如本文中所示,本实施例以下是HTTP GET请求的响应。我可以看到下面的code连接有几个不同的选项,比如存款,取款,转移和关闭。

As shown in the article, this below example is a response to a HTTP GET request. I can see that the below code have several different options attached, like deposit, withdraw, transfer and close.

<?xml version="1.0"?>
<account>
   <account_number>12345</account_number>
   <balance currency="usd">100.00</balance>
   <link rel="deposit" href="http://somebank.org/account/12345/deposit" />
   <link rel="withdraw" href="http://somebank.org/account/12345/withdraw" /> 
   <link rel="transfer" href="http://somebank.org/account/12345/transfer" />
   <link rel="close" href="http://somebank.org/account/12345/close" />
 </account>

所以是一种基于发现的REST API实际上只是所有关于该响应还给了不同的posibilities有系统(OFC只有那些逻辑以正确的顺序提)?

So is a discovery based REST API really just all about that the response "ALSO" gives the different posibilities there is in the system (ofc only the logical ones to mention in the correct order) ?

推荐答案

是的,你是正确的:在该系统上,为特别资源。

Yes, you are correct: in that system for that particular resource.

在你的榜样,试想余额为0美元,银行的政策规定,你不能没有一个积极的平衡取钱。 提款链接是从选项列表中不存在的。

Imagine in your example the balance is 0 USD and bank policy states you cannot withdraw money without a positive balance. The "withdraw" link would be absent from the list of options.

这篇关于基于REST API中发现什么是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆