Skip to content
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

ResponseWriter optional interfaces #216

Open
phillebaba opened this issue Mar 18, 2024 · 0 comments
Open

ResponseWriter optional interfaces #216

phillebaba opened this issue Mar 18, 2024 · 0 comments

Comments

@phillebaba
Copy link

The current implementation of the standard lib implementation uses a wrapper of the response writer to capture status and other information. While it does conform to the interfaces required function it does not implement optional interfaces which are useful. As the this is run as a middleware before any handlers it means that all handlers will receive the wrapped response writer which as well.

This has the most noticeable impact when using io copy to write from a reader, as a zero copy system call will not be used. Instead Go will fallback to using an in memory buffer instead.

It is not the most logical side effect, and it is pretty easy to miss as the response writer is hidden and itself does not do a good job documenting the additional optional interfaces.

Here is a good blog post that explains the issue well.
https://avtok.com/2014/11/05/interface-upgrades.html

My suggestion is that we implement the ReadFrom function on the response writer so that io copy will work more efficiently for all users who may not be aware of the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant