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

adding method to return the hostname where httpbin is running #66

Closed
wants to merge 4 commits into from

Conversation

uromahn
Copy link

@uromahn uromahn commented Oct 13, 2021

I wanted a method that identifies the host httpbin is running on and returns the hostname.

Copy link
Owner

@mccutchen mccutchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I think this is a nice idea, thanks! I left a couple of small comments below, let me know what you think.

I’m on vacation this week (reviewing from phone), so probably won’t get a chance to try this out till Sunday. Thanks for your patience!

httpbin/handlers.go Outdated Show resolved Hide resolved
httpbin/handlers_test.go Outdated Show resolved Hide resolved
@mccutchen
Copy link
Owner

Hey @uromahn, I'm sorry for the long delay in getting back to this. Would you mind letting me know what your use case is for this feature?

Having thought about it for a while, I no longer think this is a good feature to add. The rest of go-httpbin's functionality is about the incoming HTTP request, the client making the request, or exercising interesting characteristics in HTTP responses.

This would be the first feature to intentionally[1] reveal something about the underlying infrastructure, and I don't want to add that unless there's a good reason to do so, and I can't think of one myself!

[1] I say "intentionally" here because some infra details are likely leaked in response headers added by the platform where a go-httpbin instance is hosted, but that's relatively unavoidable.

@mccutchen
Copy link
Owner

Closing for now, will reopen if there's a compelling use case for this functionality!

@mccutchen mccutchen closed this Nov 3, 2021
@x70b1
Copy link
Contributor

x70b1 commented Jun 30, 2022

I understand the argument that this would be the first infrastructure related information and maybe it fits not perfectly into httpbin.

My experience: I was debugging around on a haproxy and worked on the load balancing setup in a containerized environment.
I found httpbin and go-httpbin. It was the perfect tool as it gives a lot of information about the request details and so on. But I also asked me "On wich backend webserver are I am at the moment?". I found this PR but unfortunately it was closed.

A workaround was to add the requested server as information to the header, so that httpbin returns this value in its response back to my browser. But it would be much easier if httpbin could just return this. (Or something else where I can distinguish between 2 httpbin instances.) So I would like to see this feature.

@mccutchen
Copy link
Owner

Ah, that is an interesting use case! If we were to enable this functionality, I'd want to make it opt-in only to avoid unexpectedly revealing more information about existing go-httpbin instances than we were previously revealing.

Would that work for your use case?

@x70b1
Copy link
Contributor

x70b1 commented Jul 1, 2022

Yeah, that's probably something that we don't want to expose by default.
Opt-in sounds good. A cli flag would be perfect.

mccutchen added a commit that referenced this pull request Jul 1, 2022
This adds a new /hostname endpoint as originally proposed in #66. In
this implementation, it exposes a dummy hostname by default, and only
exposes the real hostname (via `os.Hostname()`) if the
`-expose-real-hostname` flag is given on the command line.
mccutchen added a commit that referenced this pull request Jul 3, 2022
This adds a new /hostname endpoint as originally proposed in #66. In
this implementation, it exposes a dummy hostname by default, and only
exposes the real hostname (via `os.Hostname()`) if the
`-expose-real-hostname` flag is given on the command line.
mccutchen added a commit that referenced this pull request Jul 3, 2022
This adds a new /hostname endpoint as originally proposed in #66. In
this implementation, it exposes a dummy hostname by default, and only
exposes the real hostname (via `os.Hostname()`) if the
`-expose-real-hostname` flag is given on the command line.
mccutchen added a commit that referenced this pull request Jul 5, 2022
This adds a new /hostname endpoint as originally proposed in #66. In
this implementation, it exposes a dummy hostname by default, and only
exposes the real hostname (via `os.Hostname()`) if the
`-use-real-hostname` flag is given on the command line.
@mccutchen mccutchen mentioned this pull request Jul 5, 2022
mccutchen added a commit that referenced this pull request Jul 5, 2022
This adds a new /hostname endpoint as originally proposed in #66. In
this implementation, it exposes a dummy hostname by default, and only
exposes the real hostname (via `os.Hostname()`) if the
`-use-real-hostname` flag is given on the command line.
@mccutchen
Copy link
Owner

FYI for anyone watching this pull request: this was added in #81, but disabled by default.

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

Successfully merging this pull request may close these issues.

3 participants