rest: Specify rest_dispatch handlers by function, not by string.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-09-21 18:55:32 -07:00
committed by Tim Abbott
parent faf600e9f5
commit e70f2ae58d
8 changed files with 190 additions and 183 deletions

View File

@@ -140,9 +140,9 @@ yields a response with this HTTP header:
We can see this reflected in [zproject/urls.py](https://github.com/zulip/zulip/blob/master/zproject/urls.py):
path('users', 'zerver.lib.rest.rest_dispatch',
{'GET': 'zerver.views.users.get_members_backend',
'PUT': 'zerver.views.users.create_user_backend'}),
path('users', zerver.lib.rest.rest_dispatch,
{'GET': zerver.views.users.get_members_backend,
'PUT': zerver.views.users.create_user_backend}),
In this way, the API is partially self-documenting.
@@ -176,8 +176,8 @@ the request, and then figure out which view to show from that.
In our example,
```
{'GET': 'zerver.views.users.get_members_backend',
'PUT': 'zerver.views.users.create_user_backend'}
{'GET': zerver.views.users.get_members_backend,
'PUT': zerver.views.users.create_user_backend}
```
is supplied as an argument to `rest_dispatch`, along with the