title: Sinatra - how do I get the server's domain name
body: <p>I'm trying to get the domain name in my Sinatra app but as a newbie I really am struggling to figure out how to do this, and I know it must be possible!</p>
  
  <p><code>Rack::Request#host_with_port</code> looks promising, but I don't know how to get this from my app - how do I get stuff from Rack in my Ruby code?</p>
  
  <p>Or is there another way - I'm thinking I don't really want to do this every time a request happens (although it's not too bad), but I thought it'd be better if I could just do it once when the application loads up.</p>
  
  <p>Any hints?</p>