log invalid api requests
This commit is contained in:
parent
03daede441
commit
a24d96b098
1 changed files with 9 additions and 2 deletions
|
@ -34,8 +34,15 @@ def api(request):
|
||||||
return response
|
return response
|
||||||
if request.META.get('CONTENT_TYPE') == 'application/json':
|
if request.META.get('CONTENT_TYPE') == 'application/json':
|
||||||
r = json.loads(request.body.decode('utf-8'))
|
r = json.loads(request.body.decode('utf-8'))
|
||||||
action = r['action']
|
if 'action' not in r:
|
||||||
data = r.get('data', {})
|
logger.error("invalid api request: %s", r)
|
||||||
|
response = render_to_json_response(json_response(status=400,
|
||||||
|
text='Invalid request'))
|
||||||
|
response['Access-Control-Allow-Origin'] = '*'
|
||||||
|
return response
|
||||||
|
else:
|
||||||
|
action = r['action']
|
||||||
|
data = r.get('data', {})
|
||||||
else:
|
else:
|
||||||
action = request.POST['action']
|
action = request.POST['action']
|
||||||
data = json.loads(request.POST.get('data', '{}'))
|
data = json.loads(request.POST.get('data', '{}'))
|
||||||
|
|
Loading…
Reference in a new issue