blob: b62c2319ab359d2ca419aa6992282fd65910ec7e (
plain)
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
|
package main
import (
"log"
"net"
pb "github.com/bazelbuild/rules_go/examples/proto/grpc/my_svc_proto"
lpb "github.com/bazelbuild/rules_go/examples/proto/lib/lib_proto"
apb "github.com/golang/protobuf/ptypes/any"
epb "github.com/golang/protobuf/ptypes/empty"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
type server struct{}
func (s *server) Get(ctx context.Context, req *pb.GetRequest) (*epb.Empty, error) {
return &epb.Empty{}, nil
}
func (s *server) Put(ctx context.Context, req *apb.Any) (*lpb.LibObject, error) {
return &lpb.LibObject{}, nil
}
func main() {
lis, err := net.Listen("tcp", ":8080")
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer()
pb.RegisterMyServiceServer(s, &server{})
s.Serve(lis)
}
|