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

Refactor: Use http and httputil libraries from the Go standard library #290

Closed
cjlarose opened this issue Nov 22, 2021 · 1 comment · Fixed by #304
Closed

Refactor: Use http and httputil libraries from the Go standard library #290

cjlarose opened this issue Nov 22, 2021 · 1 comment · Fixed by #304

Comments

@cjlarose
Copy link
Member

cjlarose commented Nov 22, 2021

The httpu package in this repo appears to be an older version of the standard library http package. The u in the name of the package, I think, was meant to call out that it supports HTTP over Unix Domain Sockets. Modern versions of the http package in the Go standard library support doing this, though the API has changed (httpu, I think, might have been copied prior to the Go 1.0 release). In particular, it seems necessary to net.Dial the Unix Domain socket path in the transport and the URIs are a bit different now (The http:// scheme is used instead of httpu://).

The httputil package similarly appears to be a vendored version of the Go standard library package by the same name. It might have been copied, as with the http package, prior to the 1.0 release because the API for defining a reverse proxy has changed when comparing it to the modern version. Most relevant for this project, the Proxy property of the ReverseProxy has been replaced with a Director property, which 1) doesn't have the ability to write a response directly and 2) doesn't allow an error to be returned. For both changes, the path forward seems to be to compose multiple HTTP handlers instead of putting all of the logic into the ReverseProxy itself.

Anyway, I got a proof-of-concept working that works for HTTP-over-Unix Domain Sockets but broke HTTP=>HTTP proxying and also static files serving along the way. It's at https://github.com/cjlarose/puma-dev/tree/update-to-stdlib-httputil and very messy, but I wanted to open up this issue to see if a change to switch these packages over to the modern versions would be welcome or if there's some reason to keep around the old versions. I'd likely open multiple, incremental PRs to refactor stuff to make the transition easier.

@nonrational
Copy link
Member

The first phase (#292) as been released in v0.18.1

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

Successfully merging a pull request may close this issue.

2 participants