micro/template/handler/example.go

26 lines
567 B
Go
Raw Normal View History

2015-01-14 02:31:27 +03:00
package handler
import (
2015-01-31 18:49:21 +03:00
log "github.com/golang/glog"
2015-05-23 13:53:40 +03:00
c "github.com/myodc/go-micro/context"
2015-05-05 21:05:06 +03:00
"github.com/myodc/go-micro/server"
example "github.com/myodc/go-micro/template/proto/example"
2015-05-23 13:53:40 +03:00
"golang.org/x/net/context"
2015-01-14 02:31:27 +03:00
)
type Example struct{}
func (e *Example) Call(ctx context.Context, req *example.Request, rsp *example.Response) error {
2015-05-23 13:53:40 +03: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-14 02:31:27 +03:00
2015-05-09 02:42:07 +03:00
rsp.Msg = server.Id + ": Hello " + req.Name
2015-01-14 02:31:27 +03:00
return nil
}