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
proposal: net/http: add scheme constants #40587
Comments
I think |
@seankhliao My reasoning was similar to that
of |
I don’t think these constants add anything for the reader. The literals |
@davecheney My main concern here are possible
misspellings. I've already seen |
In addition to the stutter, writing People felt strongly about adding the HTTP method constants too but in practice they're not used because As such, I'm not in favor of this. |
That is not my experience, to be honest. Unless the code base is older than the named constants, I have almost always seen the constants preferred to literals. As for the stuttering, my original proposal doesn't have that issue. |
Accepted, but the names http.Scheme and http.Secure don’t describe their contents; the former sounds like the name of a type and the latter sounds like some kind of boolean |
@davecheney I guess they could be
I would hope that packages that implement other
protocols would add their schemes in a similar fashion,
so that we could have, say, |
Based on the discussion, this seems like a likely decline. |
No change in consensus, so declined. |
Over the years I've noticed quite a lot of “magic” strings in HTTP-related code, primarily
"http"
and"https"
. There are a lot of examples innet/http/...
as well as incmd/...
.So, I propose to add these constants to
net/http
(or, perhaps,net/url
?):Example usage:
The text was updated successfully, but these errors were encountered: