-
-
Notifications
You must be signed in to change notification settings - Fork 252
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
fix: better handling of route return type #349
Conversation
✅ Deploy Preview for robyn canceled.
|
@AntoineRR , thank you for your PR. Can we still return a dictionary in this PR? |
Yes sure! |
f07b943
to
c831018
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! 🔥
I am just wondering where will we add the documentation regarding this 🤔
Hey @sansyrox, thanks for your review. I added docs regarding the types returned from a route in the |
return { | ||
"status_code": 200, | ||
"body": "This is a regular response", | ||
"type": "text", | ||
"headers": {"Header": "header_value"}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @AntoineRR ,
The return type of json should be
return {
"status_code": 200,
"body": jsonify({"hello": "world"},
"headers": {"Content-Type": "application/json"},
}
or just
return jsonify({"hello": "world"})
It will be returning a Plain Text otherwise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my bad you're right, I will change this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sansyrox it should be ok now 🙂
8f37c5c
to
7485364
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Great work! 🔥
fix: better handling of route return type (sparckles#349)
Description
I figured there are issues when you try to return something other than a string or a dict in a route. With this PR, you can return anything and most notably directly a
Response
.We may want to add it to the doc if it seems relevant to you @sansyrox ?