Skip to content

Commit

Permalink
adding optional jsonp parameter to events/get_data
Browse files Browse the repository at this point in the history
* using the same code / structure as `render`
  • Loading branch information
Yoav committed Dec 29, 2012
1 parent 6a90fe8 commit b4868c4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions webapp/graphite/events/views.py
Expand Up @@ -60,8 +60,16 @@ def post_event(request):
return HttpResponse(status=405)

def get_data(request):
return HttpResponse(json.dumps(fetch(request), cls=EventEncoder),
mimetype="application/json")
if 'jsonp' in request.REQUEST:
response = HttpResponse(
"%s(%s)" % (request.REQUEST.get('jsonp'),
json.dumps(fetch(request), cls=EventEncoder)),
mimetype='text/javascript')
else:
response = HttpResponse(
json.dumps(fetch(request), cls=EventEncoder),
mimetype="application/json")
return response

def fetch(request):
if request.GET.get("from", None) is not None:
Expand Down

0 comments on commit b4868c4

Please sign in to comment.