diff --git a/hwt.go b/hwt.go index f71525f..95bba28 100644 --- a/hwt.go +++ b/hwt.go @@ -4,11 +4,15 @@ import ( "context" fmt "fmt" + "github.com/twitchtv/twirp" pb "mcquay.me/hwt/rpc/hwt" ) type Server struct{} 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 } diff --git a/rpc/hwt/service.proto b/rpc/hwt/service.proto index 9cf77fa..7313da1 100644 --- a/rpc/hwt/service.proto +++ b/rpc/hwt/service.proto @@ -9,9 +9,9 @@ service HelloWorld { } message HelloReq { - string subject = 1; + string subject = 1; // required } message HelloResp { - string text = 1; + string text = 1; // required }