Example #1
0
func makeReq(args []string, body []byte) (*msg.OcReq, error) {
	s := strings.Split(args[0], ".")
	if len(s) != 2 {
		return nil, fmt.Errorf("expected server.method, but got: %v", args[0])
	}
	reqArgs := args[1:]
	req := msg.OcReq{
		ID:            "",
		Sig:           "",
		Nonce:         "",
		Service:       s[0],
		Method:        s[1],
		Args:          reqArgs,
		PaymentType:   "",
		PaymentTxn:    "",
		ContentLength: 0,
	}
	if body != nil {
		req.SetBody(body)
		req.ContentLength = len(body)
		req.Body = body
	}
	return &req, nil
}