我们使用hyperledger composer开发和部署BNA文件作为链代码 . 我们需要自定义一些事务的返回类型,遗憾的是我们无法做到这一点,因为返回类型与输入类型相同 . 为了自定义返回类型,我们想拦截其余的api调用,并在API返回之前对输出进行更改 . 为了实现上述目标,我有2个问题 -
1)当我们调用JS文件拦截请求的restapi时?
2)如果有人可以帮助我们理解超级边缘编写器端到端处理事务休息api调用的方式,会有所帮助吗?
我们使用hyperledger fabric 1.0来存储区块链 .
用于创建或更新名为Customer的资产的其余api调用的示例curl语句
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{}' 'https://<serverinst>:3000/api/Customer'
请求机构 -
{
"$class": "org.network.garment.Customer",
"CustomerId": "string",
"Address1": "string",
"Address2": "string",
"Authkey": "string",
"City": "string",
"Country": "string",
"Email": "string",
"Mobile": "string",
"State": "string",
"UserType": 0
}
任何帮助表示赞赏 .
1 回答
它使用了Loopback框架 - 这里有更多关于Composer REST服务器的信息https://github.com/hyperledger/composer/wiki/Composer-REST-Server . 您可以生成自己的自定义REST服务器(相当于功能中的Composer REST服务器)来自定义https://hyperledger.github.io/composer/latest/integrating/customizing-the-rest-server - 这将生成Loopback 3应用程序 .
此博客应该有助于自定义您的返回类型 - > https://dzone.com/articles/customization-of-rest-apis-in-loopback-application