micro/template/handler/example.go

26 lines
567 B
Go
Raw Normal View History

2015-01-13 23:31:27 +00:00
package handler
import (
2015-01-31 16:49:21 +01:00
log "github.com/golang/glog"
2015-05-23 11:53:40 +01:00
c "github.com/myodc/go-micro/context"
2015-05-05 19:05:06 +01:00
"github.com/myodc/go-micro/server"
example "github.com/myodc/go-micro/template/proto/example"
2015-05-23 11:53:40 +01:00
"golang.org/x/net/context"
2015-01-13 23:31:27 +00:00
)
type Example struct{}
func (e *Example) Call(ctx context.Context, req *example.Request, rsp *example.Response) error {
2015-05-23 11:53:40 +01:00
md, ok := c.GetMetaData(ctx)
if ok {
log.Infof("Received Example.Call request with metadata: %v", md)
} else {
log.Info("Received Example.Call request")
}
2015-01-13 23:31:27 +00:00
2015-05-09 00:42:07 +01:00
rsp.Msg = server.Id + ": Hello " + req.Name
2015-01-13 23:31:27 +00:00
return nil
}