log invalid api requests
This commit is contained in:
parent
03daede441
commit
a24d96b098
1 changed files with 9 additions and 2 deletions
|
@ -34,6 +34,13 @@ 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'))
|
||||||
|
if 'action' not in r:
|
||||||
|
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']
|
action = r['action']
|
||||||
data = r.get('data', {})
|
data = r.get('data', {})
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue