...
1 package server
2
3 import (
4 "context"
5
6 "github.com/golang/glog"
7 examples "github.com/grpc-ecosystem/grpc-gateway/examples/internal/proto/examplepb"
8 "google.golang.org/grpc"
9 "google.golang.org/grpc/metadata"
10 )
11
12
13
14 type unannotatedEchoServer struct{}
15
16 func newUnannotatedEchoServer() examples.UnannotatedEchoServiceServer {
17 return new(unannotatedEchoServer)
18 }
19
20 func (s *unannotatedEchoServer) Echo(ctx context.Context, msg *examples.UnannotatedSimpleMessage) (*examples.UnannotatedSimpleMessage, error) {
21 glog.Info(msg)
22 return msg, nil
23 }
24
25 func (s *unannotatedEchoServer) EchoBody(ctx context.Context, msg *examples.UnannotatedSimpleMessage) (*examples.UnannotatedSimpleMessage, error) {
26 glog.Info(msg)
27 grpc.SendHeader(ctx, metadata.New(map[string]string{
28 "foo": "foo1",
29 "bar": "bar1",
30 }))
31 grpc.SetTrailer(ctx, metadata.New(map[string]string{
32 "foo": "foo2",
33 "bar": "bar2",
34 }))
35 return msg, nil
36 }
37
38 func (s *unannotatedEchoServer) EchoDelete(ctx context.Context, msg *examples.UnannotatedSimpleMessage) (*examples.UnannotatedSimpleMessage, error) {
39 glog.Info(msg)
40 return msg, nil
41 }
42
View as plain text