Add hostname to response

This commit is contained in:
sm
2018-01-20 09:07:57 -08:00
parent 19c1adde6f
commit 2f0c01df7a
3 changed files with 16 additions and 3 deletions
+9 -2
View File
@@ -8,11 +8,18 @@ import (
pb "mcquay.me/hwt/rpc/hwt"
)
type Server struct{}
type Server struct {
Hostname string
}
func (s *Server) Hello(ctx context.Context, req *pb.HelloReq) (*pb.HelloResp, error) {
if req.Subject == "" {
return nil, twirp.RequiredArgumentError("subject")
}
return &pb.HelloResp{Text: fmt.Sprintf("echo: %v", req.Subject)}, nil
r := &pb.HelloResp{
Text: fmt.Sprintf("echo: %v", req.Subject),
Hostname: s.Hostname,
}
return r, nil
}