forked from stackedsax/deis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouters.py
49 lines (44 loc) · 1.27 KB
/
routers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
REST framework URL routing classes.
"""
from __future__ import unicode_literals
from rest_framework.routers import DefaultRouter
from rest_framework.routers import Route
class ApiRouter(DefaultRouter):
"""Generate URL patterns for list, detail, and viewset-specific
HTTP routes.
"""
routes = [
# List route.
Route(
url=r"^{prefix}/?$",
mapping={
'get': 'list',
'post': 'create'
},
name="{basename}-list",
initkwargs={'suffix': 'List'}
),
# Detail route.
Route(
url=r"^{prefix}/{lookup}/?$",
mapping={
'get': 'retrieve',
'put': 'update',
'patch': 'partial_update',
'delete': 'destroy'
},
name="{basename}-detail",
initkwargs={'suffix': 'Instance'}
),
# Dynamically generated routes, from @action or @link decorators
# on methods of the viewset.
Route(
url=r"^{prefix}/{lookup}/{methodname}/?$",
mapping={
"{httpmethod}": "{methodname}",
},
name="{basename}-{methodnamehyphen}",
initkwargs={}
),
]