mirror of
https://github.com/genuinetools/reg.git
synced 2024-08-17 12:30:23 -04:00
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"github.com/golang/glog"
|
|
examples "github.com/grpc-ecosystem/grpc-gateway/examples/proto/examplepb"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/metadata"
|
|
)
|
|
|
|
// Implements of UnannotatedEchoServiceServer
|
|
|
|
type unannotatedEchoServer struct{}
|
|
|
|
func newUnannotatedEchoServer() examples.UnannotatedEchoServiceServer {
|
|
return new(unannotatedEchoServer)
|
|
}
|
|
|
|
func (s *unannotatedEchoServer) Echo(ctx context.Context, msg *examples.UnannotatedSimpleMessage) (*examples.UnannotatedSimpleMessage, error) {
|
|
glog.Info(msg)
|
|
return msg, nil
|
|
}
|
|
|
|
func (s *unannotatedEchoServer) EchoBody(ctx context.Context, msg *examples.UnannotatedSimpleMessage) (*examples.UnannotatedSimpleMessage, 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
|
|
}
|
|
|
|
func (s *unannotatedEchoServer) EchoDelete(ctx context.Context, msg *examples.UnannotatedSimpleMessage) (*examples.UnannotatedSimpleMessage, error) {
|
|
glog.Info(msg)
|
|
return msg, nil
|
|
}
|