github.com/grpc-ecosystem/grpc-gateway/v2@v2.19.1/examples/internal/server/unannotatedecho.go (about) 1 package server 2 3 import ( 4 "context" 5 6 examples "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" 7 "google.golang.org/grpc" 8 "google.golang.org/grpc/grpclog" 9 "google.golang.org/grpc/metadata" 10 ) 11 12 // Implements of UnannotatedEchoServiceServer 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 grpclog.Info(msg) 22 return msg, nil 23 } 24 25 func (s *unannotatedEchoServer) EchoBody(ctx context.Context, msg *examples.UnannotatedSimpleMessage) (*examples.UnannotatedSimpleMessage, error) { 26 grpclog.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 grpclog.Info(msg) 40 return msg, nil 41 }