forked from johanbrandhorst/grpc-gateway-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (35 loc) · 1.04 KB
/
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
package main
import (
"io/ioutil"
"net"
"os"
"github.com/widerschein/grpc-gateway-boilerplate/gateway"
"github.com/widerschein/grpc-gateway-boilerplate/insecure"
usersv1 "github.com/widerschein/grpc-gateway-boilerplate/proto/users/v1"
"github.com/widerschein/grpc-gateway-boilerplate/server"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/grpclog"
)
func main() {
// Adds gRPC internal logs. This is quite verbose, so adjust as desired!
log := grpclog.NewLoggerV2(os.Stdout, ioutil.Discard, ioutil.Discard)
grpclog.SetLoggerV2(log)
addr := "0.0.0.0:10000"
lis, err := net.Listen("tcp", addr)
if err != nil {
log.Fatalln("Failed to listen:", err)
}
s := grpc.NewServer(
// TODO: Replace with your own certificate!
grpc.Creds(credentials.NewServerTLSFromCert(&insecure.Cert)),
)
usersv1.RegisterUserServiceServer(s, server.New())
// Serve gRPC Server
log.Info("Serving gRPC on https://", addr)
go func() {
log.Fatal(s.Serve(lis))
}()
err = gateway.Run("dns:///" + addr)
log.Fatalln(err)
}