github.com/kaiya/goutils@v1.0.1-0.20230226104005-4ae4a4dc3688/tinyrpc/core/core.go (about)

     1  package core
     2  
     3  import "errors"
     4  
     5  type Response struct {
     6  	Message string
     7  }
     8  
     9  type Request struct {
    10  	Name string
    11  }
    12  
    13  var HandlerName = "Handler.Execute"
    14  
    15  type Handler struct{}
    16  
    17  func (h *Handler) Execute(req Request, res *Response) (err error) {
    18  	if req.Name == "" {
    19  		err = errors.New("A name must be specified")
    20  		return
    21  	}
    22  
    23  	res.Message = "Hello " + req.Name
    24  	return
    25  }