mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
* REST api added for asset transfer in Golang Signed-off-by: Basil K Y <techiebasil@gmail.com> * add go.sum to git Signed-off-by: Basil K Y <techiebasil@gmail.com> * fix golint error Signed-off-by: Basil K Y <techiebasil@gmail.com> Signed-off-by: Basil K Y <techiebasil@gmail.com>
31 lines
677 B
Go
31 lines
677 B
Go
package web
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/hyperledger/fabric-gateway/pkg/client"
|
|
)
|
|
|
|
// OrgSetup contains organization's config to interact with the network.
|
|
type OrgSetup struct {
|
|
OrgName string
|
|
MSPID string
|
|
CryptoPath string
|
|
CertPath string
|
|
KeyPath string
|
|
TLSCertPath string
|
|
PeerEndpoint string
|
|
GatewayPeer string
|
|
Gateway client.Gateway
|
|
}
|
|
|
|
// Serve starts http web server.
|
|
func Serve(setups OrgSetup) {
|
|
http.HandleFunc("/query", setups.Query)
|
|
http.HandleFunc("/invoke", setups.Invoke)
|
|
fmt.Println("Listening (http://localhost:3000/)...")
|
|
if err := http.ListenAndServe(":3000", nil); err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
}
|