cloudfoundry-community / node-cfenv

easy access to your Cloud Foundry application environment for node
Apache License 2.0
73 stars 20 forks source link

add a localUrl for callbacks? #5

Closed srl295 closed 8 years ago

srl295 commented 9 years ago

If an app wants to call itself, could there be a localUrl property that is something like:

 http://localhost:<port>/

Perhaps instead of localhost it should be <bind>, unless <bind> is 0.0.0.0 in which case localhost is still appropriate?

pmuellr commented 9 years ago

The intention is that appEnv.url should be good enough for this. The problem with this is - when running in CF - is that it will route HTTP requests back through the gorouter (and any other front-end provided by the CF installation), causing actual network traffic instead of a loopback through localhost, which wouldn't cause any network traffic.

So, you can imagine that this might be desired.

However, in such cases, if you really DID want to route right back to the same server instance you were invoked with, then it seems like you could easily avoid HTTP altogether.

So, wondering what the real use case is.

Also, a little worried that resolving localhost:$PORT would not always work - I would certainly HOPE that it would, but I'm not sure anyone does this, so seems like an edge case that could go bad at some point.

srl295 commented 9 years ago

There's no requirement that localhost or 127.0.0.1 exist or work. However if bind is 0.0.0.0 then any network interface should work.

It's not a great use case, but node-uptime tries to call itself using http://<localhost>:<port>/api/<something>.

pmuellr commented 9 years ago

I'm confused on what the real need is here. What are the use cases, and expected results?

pmuellr commented 8 years ago

closing because of lack of interest; feel free to re-open