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

http pool basePath getter and/or setter? #22

Open
dvirsky opened this issue Feb 11, 2014 · 8 comments
Open

http pool basePath getter and/or setter? #22

dvirsky opened this issue Feb 11, 2014 · 8 comments

Comments

@dvirsky
Copy link

dvirsky commented Feb 11, 2014

I'm building a server that uses groupcache, and I would like to be able to conveniently wrap the http pool's handler inside a mux (specifically to add a monitoring status call on the server).

I simply thought of adding a handler func that forwards everything under /_groupcache/ to groupcache's handler. But this will fail if ever the hard coded base path will change.

So I thought of adding at least a getter, if not a setter for the base path. I understand the consistency problem with adding a setter. Will a pull request for GetBasePath() and/or SetBasePath() be accepted?

@nf
Copy link
Contributor

nf commented Feb 13, 2014

Can't you just wrap the handler with http.StripPrefix/

@dvirsky
Copy link
Author

dvirsky commented Feb 13, 2014

The way I understand it no, but I'd gladly stand corrected. Groupcache handles everything by default, and panics if that doesn't begin with its basePath (/_groupcache), that is not configurable (and has the comment: // TODO: make this configurable?), is not exported and doesn't have a getter.

I just hard coded that into my code, but you know, it feels wrong :)

@nf
Copy link
Contributor

nf commented Feb 13, 2014

I wouldn't be opposed to adding these methods:

BasePath() string
SetBasePath(p string)

@dvirsky
Copy link
Author

dvirsky commented Feb 14, 2014

Alright, I'll gladly do this and add do a PR.

@dvirsky
Copy link
Author

dvirsky commented Feb 14, 2014

@nf wouldn't it be a tad more elegant, instead of adding a setter to simply add in http.go (67):

func NewHTTPPool(self, basePath string) *HTTPPool  {
...

I mean, you wouldn't change the basePath during serving.

@nf
Copy link
Contributor

nf commented Feb 15, 2014

Yep, probably.

@nf
Copy link
Contributor

nf commented Feb 15, 2014

Do that :-)

@shwoodard
Copy link

I just hit this, I'd even be happy if defaultBasePath was DefaultBasePath so that muxer registration wasn't by a copy of the constant.

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

No branches or pull requests

4 participants