fabric-samples/asset-transfer-basic/rest-api-go/web/app.go
Basil K Y b2de360e1c
REST api added for asset transfer in Golang (#836)
* 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>
2022-12-14 09:16:09 +01:00

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)
}
}