1
0
bthlabs-jsonrpc/packages/bthlabs-jsonrpc-django/docs/source/overview.rst

58 lines
1.1 KiB
ReStructuredText
Raw Permalink Normal View History

Overview
========
This section provides the general overview of the integration.
Installation
------------
.. code-block:: shell
$ pip install bthlabs_jsonrpc_django
Usage
-----
First, you'll need to enable the application by adding it to
``INSTALLED_APPS``:
.. code-block:: python
# settings.py
INSTALLED_APPS = [
# ...
'bthlabs_jsonrpc_django',
]
Then, you'll need to add your RPC method modules to ``JSONRPC_METHOD_MODULES``
setting:
.. code-block:: python
# settings.py
JSONRPC_METHOD_MODULES = [
# ...
'your_app.rpc_methods',
]
After that, you'll need to add a JSONRPC view to your project's URLs:
.. code-block:: python
# urls.py
urlpatterns = [
# ...
path('rpc', JSONRPCView.as_view()),
]
Last but not least, you'll need to implement the RPC method modules:
.. code-block:: python
# 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}!'