mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 14:08:23 +00:00
Implement URLs for API redesign.
(imported from commit 2020491a737ec4c1e99a63f84eb6cfc594a2dd56)
This commit is contained in:
@@ -109,11 +109,40 @@ 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',
|
||||||
|
'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',
|
||||||
|
'POST': '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'}),
|
||||||
)
|
)
|
||||||
|
|
||||||
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'),
|
||||||
|
url(r'^api/v1/messages/latest$', 'rest_get_messages'),
|
||||||
url(r'^json/get_updates$', 'json_get_updates'),
|
url(r'^json/get_updates$', 'json_get_updates'),
|
||||||
# Used internally for communication between Django and Tornado processes
|
# Used internally for communication between Django and Tornado processes
|
||||||
url(r'^notify_tornado$', 'notify'),
|
url(r'^notify_tornado$', 'notify'),
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ location /static/ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Send longpoll requests to Tornado
|
# Send longpoll requests to Tornado
|
||||||
location ~ /json/get_updates|/api/v1/get_messages {
|
location ~ /json/get_updates|/api/v1/get_messages|/api/v1/messages/latest {
|
||||||
proxy_pass http://localhost:9993;
|
proxy_pass http://localhost:9993;
|
||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class Resource(resource.Resource):
|
|||||||
def getChild(self, name, request):
|
def getChild(self, name, request):
|
||||||
request.requestHeaders.setRawHeaders('X-Forwarded-Host', [proxy_host])
|
request.requestHeaders.setRawHeaders('X-Forwarded-Host', [proxy_host])
|
||||||
|
|
||||||
if request.uri in ['/json/get_updates', '/api/v1/get_messages']:
|
if request.uri in ['/json/get_updates', '/api/v1/get_messages', '/api/v1/messages/latest']:
|
||||||
return proxy.ReverseProxyResource('localhost', tornado_port, '/'+name)
|
return proxy.ReverseProxyResource('localhost', tornado_port, '/'+name)
|
||||||
|
|
||||||
return proxy.ReverseProxyResource('localhost', django_port, '/'+name)
|
return proxy.ReverseProxyResource('localhost', django_port, '/'+name)
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ class Command(BaseCommand):
|
|||||||
urls = (r"/json/get_updates",
|
urls = (r"/json/get_updates",
|
||||||
r"/api/v1/get_messages",
|
r"/api/v1/get_messages",
|
||||||
r"/notify_tornado",
|
r"/notify_tornado",
|
||||||
|
r"/api/v1/messages/latest",
|
||||||
)
|
)
|
||||||
# Application is an instance of Django's standard wsgi handler.
|
# Application is an instance of Django's standard wsgi handler.
|
||||||
application = web.Application([(url, AsyncDjangoHandler) for url in urls],
|
application = web.Application([(url, AsyncDjangoHandler) for url in urls],
|
||||||
|
|||||||
Reference in New Issue
Block a user