api-designjson-rpc

How to correctly pass return of one method to another in JSON-RPC in one request?


I'm making typical JSON-RPC API (based on json-rpc Python library) for the serverless E-Commerce site.

I want to register users when they are ordering something. And I'd like to do this in one request (because I'm using service like AWS Lambda). Currently I think that I may just add a merged method like Register + Order = RegisterAndOrder. But it may look ugly because JSON-RPC has support for batch requests. As I know you can't just pass return of one method to another.

Are there any other ways that I don't know?


Solution

  • I found proper solution. I need to add variable like context, that will be shared for all batch functions. If user calls register, this function will return some variables and add key-value pair to the context variable. Function order will check this key-pair. If its exists, the function will run OK. Otherwise, it will throw an exception.

    I forked JSON-RPC python library to JSON-RPC-Stateful.