-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
47 lines (35 loc) · 1020 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"github.com/golang/glog"
"golang.org/x/net/context"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"google.golang.org/grpc"
"flag"
"github.com/theQRL/walletd-rest-proxy/qrlwallet"
"net/http"
)
func run(walletServiceEndPoint string, serverIPPort string) error {
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
mux := runtime.NewServeMux()
opts := []grpc.DialOption{grpc.WithInsecure()}
err := qrlwallet.RegisterWalletAPIHandlerFromEndpoint(ctx, mux, walletServiceEndPoint, opts)
if err != nil {
return err
}
return http.ListenAndServe(serverIPPort, mux)
}
func main() {
walletServiceEndPoint := flag.String("walletServiceEndpoint",
"127.0.0.1:19010",
"endpoint of WalletAPIService")
serverIPPort := flag.String("serverIPPort",
"127.0.0.1:5359",
"IP and Port at which REST proxy will be listening")
flag.Parse()
defer glog.Flush()
if err := run(*walletServiceEndPoint, *serverIPPort); err != nil {
glog.Fatal(err)
}
}