explodinglabs / jsonrpcserver

Process incoming JSON-RPC requests in Python
MIT License
187 stars 40 forks source link

Argument to change method name in decorator? #115

Closed akuzia closed 4 years ago

akuzia commented 4 years ago

I wonder is there a convinient way to change method name? I've found some comments in Methods class, tryed to use decorators to change function __name__ values. Is there a possibility to include kwargs to method decorator, lke in jsonrpc add_method?

from jsonrpcserver import method, serve

@method(name='generic.ping')
def ping():
    return "pong"

if __name__ == "__main__":
    serve()

so calls like:

{
    "id":"d3fa8fd5-259e-9e02-6d07-25dbf49e410f",
    "jsonrpc":"2.0",
    "method":"generic.ping"
}

will be possible?

bcb commented 4 years ago

Yes I agree we should add this.

akuzia commented 4 years ago

@bcb I've looked into sources, looks like this functionality already been implemented, but was removed not so long ago in 502057335cfaa5c7fc7cc57293e89923d9a5f576, why?

bcb commented 4 years ago

I can’t remember why this was done.

Happy for it to be added back, if you want to make a PR.