0

I have a simple Rack application where part of its behaviour/configuration changes depending on the location(host and port) where it is mounted.

Rack exposes the current host and port in the Environment under SERVER_NAME and SERVER_PORT. But these are of course only passed along to the Rack app's call(env) method when the first request is made.

Because part of the setup is dependent on the location, I want to read above setting in the initialize of my Rack app's class. (How) can this be done?

Qqwy
  • 5,214
  • 5
  • 42
  • 83

1 Answers1

0

I would use theses methods, according to the fact you are in a file which belongs to the directory of your application:

working_directory = `pwd`

# or:
working_directory = File.expand_path("..", __FILE__)
Yacine
  • 221
  • 1
  • 9
  • In that way I can find out the working directory, but not if I am hosted on 127.0.0.1 or instead on 123.4.5.6 or instead on 987.6.5.4 – Qqwy Nov 03 '15 at 19:29