Skip to content

Get json from flask request #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion aikido_firewall/context/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ def set_flask_attrs(self, req):
"""Set properties that are specific to flask"""
self.remote_address = req.remote_addr
self.url = req.url
self.body = req.form.to_dict()
if req.is_json:
self.body = req.json
else:
self.body = req.form.to_dict()
self.query = req.args.to_dict()
self.cookies = req.cookies.to_dict()

Expand Down
1 change: 1 addition & 0 deletions aikido_firewall/context/init_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def test_context_init_flask(mocker):
req.method = "GET"
req.remote_addr = "127.0.0.1"
req.url = "http://example.com"
req.is_json = False
req.form.to_dict.return_value = {"key": "value"}
req.headers = {"Content-Type": "application/json"}
req.args.to_dict.return_value = {"key": "value"}
Expand Down
Loading