mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
Implement generic rest_dispatch method for new API.
(imported from commit 912ee803db03098f195d18648ab98401915fead6)
This commit is contained in:
@@ -1,6 +1,20 @@
|
||||
from django.http import HttpResponse
|
||||
from django.http import HttpResponse, HttpResponseNotAllowed
|
||||
import simplejson
|
||||
|
||||
class HttpResponseUnauthorized(HttpResponse):
|
||||
status_code = 401
|
||||
|
||||
def __init__(self, realm):
|
||||
HttpResponse.__init__(self)
|
||||
self["WWW-Authenticate"] = 'Basic realm="%s"' % realm
|
||||
|
||||
def json_method_not_allowed(methods):
|
||||
resp = HttpResponseNotAllowed(methods)
|
||||
resp.content = simplejson.dumps({"result": "error",
|
||||
"msg": "Method Not Allowed",
|
||||
"allowed_methods": methods})
|
||||
return resp
|
||||
|
||||
def json_response(res_type="success", msg="", data={}, status=200):
|
||||
content = {"result": res_type, "msg": msg}
|
||||
content.update(data)
|
||||
|
||||
Reference in New Issue
Block a user