-
Notifications
You must be signed in to change notification settings - Fork 425
refactor: remove new request with context #1857
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
Conversation
|
Can we just deprecate the old symbol and explain in the docs that it is useless? No need to break existing code for this IMHO. |
|
Alright, |
|
|
||
| // ServeHTTP executes a PHP script according to the given context. | ||
| func ServeHTTP(responseWriter http.ResponseWriter, request *http.Request) error { | ||
| func ServeHTTP(responseWriter http.ResponseWriter, request *http.Request, opts ...RequestOption) error { |
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.
Why adding a new parameter instead of using the request context?
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.
This way we only need to expose 1 function instead of 2 and don't have to do the additional allocation via the context. It's more about clarity though, directly passing a request with options just leaves less room for errors.
|
Another problem with this approach is that it's not possible anymore to expose some public custom values through the context to the calling code. It's a common practice for logging, tracing etc, for instance. TBH, I'm not sure this change is worth it. |
|
Not yet sure if exposing values via context is even a good idea, so I might revive a version of this at some point. |
This PR removes
NewRequestWithContext(slight breaking change for library users).Instead of:
Just: