Skip to content

Commit

Permalink
fix: parse int status code to str (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen authored Aug 17, 2022
1 parent a75c9b6 commit 3abe5cb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions integration_tests/base_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ def return_404_post():
return {"status_code": "404", "body": "hello", "type": "text"}


@app.get('/int_status_code')
def return_int_status_code():
return {"status_code": 202, "body": "hello", "type": "text"}


@app.before_request("/")
async def hello_before_request(request):
global callCount
Expand Down
5 changes: 5 additions & 0 deletions integration_tests/test_status_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ def test_307_get_request(session):
r = requests.get(f"{BASE_URL}/redirect")
assert r.text == "This is the redirected route"


def test_int_status_code(session):
r = requests.get(f"{BASE_URL}/int_status_code")
assert r.status_code == 202

3 changes: 3 additions & 0 deletions robyn/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def _format_response(self, res):
res["status_code"] = "200"
response = res
else:
if type(res["status_code"]) == int:
res["status_code"] = str(res["status_code"])

response = {
"status_code": "200",
"body": res["body"],
Expand Down

0 comments on commit 3abe5cb

Please sign in to comment.