-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
x/net/trace: export http.Handlers #20478
Comments
Furthermore, having
|
@zombiezen, I'd like to survey all global registrations and export handlers where we don't. I am strongly +1ing to export handlers from x/net/trace. @ahmetb, are you vendoring in libraries? Unfortunately, libraries vendoring their dependencies is not a properly supported feature, we suggest only the main packages should vendor dependencies. I'd love to avoid global registration on the default mux, but these inits have been put in place in the past and I am not sure if we can break the behavior -- especially the standard library's. |
Note that this bug is for |
Closed via golang/net@1816238. |
considering a popular golang library like this; it's most likely to get imported by multiple different packages. |
What version of Go are you using (
go version
)?go version go1.8.1 darwin/amd64
What operating system and processor architecture are you using (
go env
)?What did you do?
My program exposes an admin HTTP API, for a variety of internal routes, as well as pprof and expvar. For this it uses its own http.ServeMux (actually a gorilla/mux.Router, but it's irrelevant) into which I register routes explicitly:
I'm now wanting to expose the x/net/trace handlers (specifically /debug/events, for go-conntrack).
What did you expect to see?
I expected to be able to do something like
What did you see instead?
No such Handler functions are exposed by the trace package. Instead, the trace package assumes its users will always want it to register its routes into the http.DefaultServeMux, and performs those registrations as an import side effect, as part of package init.
Please expose the code in func init as individual handlers, so users who don't use the DefaultServeMux can still have access to x/net/trace functionality.
The text was updated successfully, but these errors were encountered: