-
-
Notifications
You must be signed in to change notification settings - Fork 543
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
Unify how we allow to set headers and status code #1579
Comments
Maybe providing some methods on context? Also can we be sure that we can abstract away different server implementations? I know for example that ASGI running background tasks but Django doesn't. |
I was thinking of having a new property that had those methods
I'd just go for headers and status code for now, we can keep access to the framework's request object if people need to do something more specific :) |
Had a thought: if we construct our own info object then we could attach this object/method to the info object rather than through context? I think that makes more sense because context is defined mostly in user land. |
something like: def a_resolver(info: Info) -> str:
info.request.headers["example"]
info.response.set_header("X-Framework", "Strawberry")
return "ABC" ? |
We should do this for cookies as well (even if they are just headers :)) |
Yes I think that looks good. |
I have two questions re this:
So I was just thinking maybe define two abstract base classes, like
So then it would be up to integrations to implement and provide |
So at the moment we have a few integrations and they have a slightly different way to setting headers and status code.
The general idea is the same, we provide a
response
object ininfo.context
. This object is based on the current integration, this is where the differences between integrations come into play.I think we should provide a new object (unfortunately we can't replace the current one due to backwards compatibility) that allows to:
Having this could also help us prevent some mistakes, for example, should we allow to set the status code multiple times?
What do you think?
Upvote & Fund
The text was updated successfully, but these errors were encountered: