0

We are using hyperledger composer to develop and deploy BNA files as chaincodes. We need to customize the return type of some of the transaction which unfortunately we are unable to do as the return type is taken to be the same as the input type. In order to customize the return type we want to intercept the rest api call and make changes to the output just before the API returns. In order to achieve the above, i have 2 questions -

1) When we invoke the restapi which JS file intercepts the request?

2) It would help if someone can help us in understanding how the a transaction rest api call is processed by hyperledger composer end to end?

we are using hyperledger fabric 1.0 for storing the blockchain.

Example curl statement for the rest api call to create or update an asset called, Customer-

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{}' 'https://<serverinst>:3000/api/Customer'

request body -

{
"$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
}

Any help is appreciated.

1 Answer 1

1

It uses the Loopback framework under the covers - so more info on Composer REST server here https://github.com/hyperledger/composer/wiki/Composer-REST-Server. You can generate your own customised REST server (that is equivalent to Composer REST server in functionality) to customise as you wish https://hyperledger.github.io/composer/latest/integrating/customizing-the-rest-server - this will generate a Loopback 3 application.

This blog should be useful concerning customising your return types -> https://dzone.com/articles/customization-of-rest-apis-in-loopback-application

1
  • thanks for all the pointers. shall update you back on how it went. Jul 4, 2018 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.