mirror of https://github.com/zulip/zulip.git
Make REST API urls available under /json/
Now we can begin the transition of the app to the same interface that our API clients use. (imported from commit 5b5001237722692f27f5de687f01d97fa0b87ed0)
This commit is contained in:
parent
b6cfb40140
commit
ddf0189307
|
@ -1,5 +1,5 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls import patterns, url
|
from django.conf.urls import patterns, url, include
|
||||||
from django.views.generic import TemplateView, RedirectView
|
from django.views.generic import TemplateView, RedirectView
|
||||||
import os.path
|
import os.path
|
||||||
import zephyr.forms
|
import zephyr.forms
|
||||||
|
@ -130,37 +130,6 @@ urlpatterns += patterns('zephyr.views',
|
||||||
# This json format view used by the API accepts a username password/pair and returns an API key.
|
# This json format view used by the API accepts a username password/pair and returns an API key.
|
||||||
url(r'^api/v1/fetch_api_key$', 'api_fetch_api_key'),
|
url(r'^api/v1/fetch_api_key$', 'api_fetch_api_key'),
|
||||||
|
|
||||||
# JSON format views used by the redesigned API, accept basic auth username:password.
|
|
||||||
# GET returns messages, possibly filtered, POST sends a message
|
|
||||||
url(r'^api/v1/messages$', 'rest_dispatch',
|
|
||||||
{'GET': 'get_old_messages_backend',
|
|
||||||
'PATCH': 'update_message_backend',
|
|
||||||
'POST': 'send_message_backend'}),
|
|
||||||
url(r'^api/v1/streams$', 'rest_dispatch',
|
|
||||||
{'GET': 'get_public_streams_backend'}),
|
|
||||||
# GET returns "stream info" (undefined currently?), HEAD returns whether stream exists (200 or 404)
|
|
||||||
url(r'^api/v1/streams/(?P<stream_name>.*)/members$', 'rest_dispatch',
|
|
||||||
{'GET': 'get_subscribers_backend'}),
|
|
||||||
url(r'^api/v1/streams/(?P<stream_name>.*)$', 'rest_dispatch',
|
|
||||||
{'HEAD': 'stream_exists_backend',
|
|
||||||
'GET': 'stream_exists_backend'}),
|
|
||||||
url(r'^api/v1/users$', 'rest_dispatch',
|
|
||||||
{'GET': 'get_members_backend'}),
|
|
||||||
url(r'^api/v1/users/me$', 'rest_dispatch',
|
|
||||||
{'GET': 'get_profile_backend'}),
|
|
||||||
url(r'^api/v1/users/me/enter-sends$', 'rest_dispatch',
|
|
||||||
{'POST': 'json_change_enter_sends'}),
|
|
||||||
url(r'^api/v1/users/me/pointer$', 'rest_dispatch',
|
|
||||||
{'GET': 'get_pointer_backend',
|
|
||||||
'PUT': 'update_pointer_backend'}),
|
|
||||||
# GET lists your streams, POST bulk adds, PATCH bulk modifies/removes
|
|
||||||
url(r'^api/v1/users/me/subscriptions$', 'rest_dispatch',
|
|
||||||
{'GET': 'list_subscriptions_backend',
|
|
||||||
'POST': 'add_subscriptions_backend',
|
|
||||||
'PATCH': 'update_subscriptions_backend'}),
|
|
||||||
url(r'^api/v1/register$', 'rest_dispatch',
|
|
||||||
{'POST': 'api_events_register'}),
|
|
||||||
|
|
||||||
# These are integration-specific web hook callbacks
|
# These are integration-specific web hook callbacks
|
||||||
url(r'^api/v1/external/beanstalk$' , 'api_beanstalk_webhook'),
|
url(r'^api/v1/external/beanstalk$' , 'api_beanstalk_webhook'),
|
||||||
url(r'^api/v1/external/github$', 'api_github_landing'),
|
url(r'^api/v1/external/github$', 'api_github_landing'),
|
||||||
|
@ -168,6 +137,40 @@ urlpatterns += patterns('zephyr.views',
|
||||||
url(r'^api/v1/external/pivotal$', 'api_pivotal_webhook'),
|
url(r'^api/v1/external/pivotal$', 'api_pivotal_webhook'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
v1_api_and_json_patterns = patterns('zephyr.views',
|
||||||
|
# JSON format views used by the redesigned API, accept basic auth username:password.
|
||||||
|
# GET returns messages, possibly filtered, POST sends a message
|
||||||
|
url(r'^messages$', 'rest_dispatch',
|
||||||
|
{'GET': 'get_old_messages_backend',
|
||||||
|
'PATCH': 'update_message_backend',
|
||||||
|
'POST': 'send_message_backend'}),
|
||||||
|
url(r'^streams$', 'rest_dispatch',
|
||||||
|
{'GET': 'get_public_streams_backend'}),
|
||||||
|
# GET returns "stream info" (undefined currently?), HEAD returns whether stream exists (200 or 404)
|
||||||
|
url(r'^streams/(?P<stream_name>.*)/members$', 'rest_dispatch',
|
||||||
|
{'GET': 'get_subscribers_backend'}),
|
||||||
|
url(r'^streams/(?P<stream_name>.*)$', 'rest_dispatch',
|
||||||
|
{'HEAD': 'stream_exists_backend',
|
||||||
|
'GET': 'stream_exists_backend'}),
|
||||||
|
url(r'^users$', 'rest_dispatch',
|
||||||
|
{'GET': 'get_members_backend'}),
|
||||||
|
url(r'^users/me$', 'rest_dispatch',
|
||||||
|
{'GET': 'get_profile_backend'}),
|
||||||
|
url(r'^users/me/enter-sends$', 'rest_dispatch',
|
||||||
|
{'POST': 'json_change_enter_sends'}),
|
||||||
|
url(r'^users/me/pointer$', 'rest_dispatch',
|
||||||
|
{'GET': 'get_pointer_backend',
|
||||||
|
'PUT': 'update_pointer_backend'}),
|
||||||
|
# GET lists your streams, POST bulk adds, PATCH bulk modifies/removes
|
||||||
|
url(r'^users/me/subscriptions$', 'rest_dispatch',
|
||||||
|
{'GET': 'list_subscriptions_backend',
|
||||||
|
'POST': 'add_subscriptions_backend',
|
||||||
|
'PATCH': 'update_subscriptions_backend'}),
|
||||||
|
url(r'^register$', 'rest_dispatch',
|
||||||
|
{'POST': 'api_events_register'}),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
urlpatterns += patterns('zephyr.tornadoviews',
|
urlpatterns += patterns('zephyr.tornadoviews',
|
||||||
# Tornado views
|
# Tornado views
|
||||||
url(r'^api/v1/get_messages$', 'api_get_messages'),
|
url(r'^api/v1/get_messages$', 'api_get_messages'),
|
||||||
|
@ -179,6 +182,13 @@ urlpatterns += patterns('zephyr.tornadoviews',
|
||||||
url(r'^notify_tornado$', 'notify'),
|
url(r'^notify_tornado$', 'notify'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Include the dual-use patterns twice
|
||||||
|
urlpatterns += patterns('',
|
||||||
|
url(r'^api/v1/', include(v1_api_and_json_patterns)),
|
||||||
|
url(r'^json/', include(v1_api_and_json_patterns)),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if not settings.DEPLOYED:
|
if not settings.DEPLOYED:
|
||||||
use_prod_static = getattr(settings, 'PIPELINE', False)
|
use_prod_static = getattr(settings, 'PIPELINE', False)
|
||||||
static_root = os.path.join(settings.DEPLOY_ROOT,
|
static_root = os.path.join(settings.DEPLOY_ROOT,
|
||||||
|
|
Loading…
Reference in New Issue