mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
Merge e4e7122a5f into a2c40e6522
This commit is contained in:
commit
917873be2d
1 changed files with 17 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package web
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
|
|
@ -18,6 +19,22 @@ func (setup *OrgSetup) Invoke(w http.ResponseWriter, r *http.Request) {
|
|||
channelID := r.FormValue("channelid")
|
||||
function := r.FormValue("function")
|
||||
args := r.Form["args"]
|
||||
|
||||
if len(args) == 1 {
|
||||
var parsed []string
|
||||
err := json.Unmarshal([]byte(args[0]), &parsed)
|
||||
if err == nil {
|
||||
args = parsed
|
||||
} else {
|
||||
fmt.Printf("Warning: failed to parse args as JSON: %s\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(args) == 0 {
|
||||
fmt.Fprintf(w, "Error: args is empty")
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("channel: %s, chaincode: %s, function: %s, args: %s\n", channelID, chainCodeName, function, args)
|
||||
network := setup.Gateway.GetNetwork(channelID)
|
||||
contract := network.GetContract(chainCodeName)
|
||||
|
|
|
|||
Loading…
Reference in a new issue