-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Change (req, res) pair to a single http context object #1292
Comments
We should consider a different name than
|
Cross-posting from a private chat:
Hmm, not really 😞 Maybe As I am thinking about this problem, I am leaning towards the conclusion that the problem is in the very fact that we have two request-related contexts: one holding req/res objects, another an instance of What if we reworked our design so that there is only a single http-request-related context object? For example: class HttpRequestContext extends Context {
constructor(
parentContext: Context,
public readonly request: ExpressRequest,
public readonly response: ExpressResponse,
// add any other required args/properties as needed) {
) {
super(parentContext);
this.bind(RestBindings.Http.REQUEST).to(this.request).lock();
this.bind(RestBindings.Http.RESPONSE).to(this.response).lock();
//...
}
} The upside is that we remove any possible confusion about what kind of an object we are receiving as a context and any code working at this low level automatically receive access to the IoC context associated with the incoming request. The potential downside is that we make it easier for low-level HTTP code to bypass dependency injection via @raymondfeng @hacksparrow thoughts? |
Would like to hear from @raymondfeng. |
I like @bajtos's proposal to consolidate the http req/res wrapper object with our IoC Context. But I do have some concerns too:
|
Responded in my pull request, let's keep the discussion there for now: #1316 (comment) |
Closing as done. |
Description / Steps to reproduce / Feature proposal
Use a single object object to contain the request and response object.
Current Behavior
(req, res)
Expected Behavior
(httpContext)
Acceptance Criteria
(req, res ...)
should be replaced with(httpContext ...)
.See Reporting Issues for more tips on writing good issues
The text was updated successfully, but these errors were encountered: