Created
April 20, 2017 01:09
-
-
Save hadv/e70b278e84842df606786186ff5918f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
“github.com/golang/glog” | |
examples “github.com/hadv/grpc” | |
“golang.org/x/net/context” | |
“google.golang.org/grpc” | |
“google.golang.org/grpc/metadata” | |
) | |
// Implements of EchoServiceServer | |
type echoServer struct{} | |
func newEchoServer() examples.EchoServiceServer { | |
return new(echoServer) | |
} | |
func (s *echoServer) Echo(ctx context.Context, msg *examples.Message) (*examples.Message, error) { | |
glog.Info(msg) | |
return msg, nil | |
} | |
func (s *echoServer) EchoBody(ctx context.Context, msg *examples.Message) (*examples.Message, error) { | |
glog.Info(msg) | |
grpc.SendHeader(ctx, metadata.New(map[string]string{ | |
“foo”: “foo1”, | |
“bar”: “bar1”, | |
})) | |
grpc.SetTrailer(ctx, metadata.New(map[string]string{ | |
“foo”: “foo2”, | |
“bar”: “bar2”, | |
})) | |
return msg, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment