Overview

This section provides the general overview of the integration.

Installation

$ pip install bthlabs_jsonrpc_django

Usage

First, you’ll need to enable the application by adding it to INSTALLED_APPS:

# settings.py
INSTALLED_APPS = [
    # ...
    'bthlabs_jsonrpc_django',
]

Then, you’ll need to add your RPC method modules to JSONRPC_METHOD_MODULES setting:

# settings.py
JSONRPC_METHOD_MODULES = [
    # ...
    'your_app.rpc_methods',
]

After that, you’ll need to add a JSONRPC view to your project’s URLs:

# urls.py
urlpatterns = [
    # ...
    path('rpc', JSONRPCView.as_view()),
]

Last but not least, you’ll need to implement the RPC method modules:

# your_app/rpc_methods.py
from bthlabs_jsonrpc_core import register_method

@register_method(name='hello')
def hello(request, who='World'):
    return f'Hello, {who}!'