Possible to read request's host in config.ru?
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
armanx <arm... @gmail.com>
Date: Sat, 22 Sep 2012 02:58:00 -0700 (PDT)
Subject: Possible to read request's host in config.ru?
Is it possible to detect the incoming request's domain name (host) in config.ru? I'm trying to use URLMap to map different domains to different apps, all running on the same IP. Theoretically, I'm trying to achieve this effect: map 'http://example1.com' do
> run MyApp::Example1 > end
map 'http://example2.com' do
> run MyApp::Example2 > end
For example, if it was possible to read rack's SERVER_NAME in config.ru, I would do something like: if SERVER_NAME == 'example1.com'
> map '/' do > run MyApp::Example1 > end > end
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Magnus Holm <judo... @gmail.com>
Date: Sat, 22 Sep 2012 12:04:03 +0200
Local: Sat, Sep 22 2012 6:04 am
Subject: Re: Possible to read request's host in config.ru?
It's already supported, you just need the trailing slash:
map 'http://example1.com/' do
run MyApp::Example1
end
// Magnus Holm
On Sat, Sep 22, 2012 at 11:58 AM, armanx <arm
... @gmail.com> wrote:
> Is it possible to detect the incoming request's domain name (host) in
> config.ru? I'm trying to use URLMap to map different domains to different
> apps, all running on the same IP. Theoretically, I'm trying to achieve this
> effect:
>> map 'http://example1.com' do
>> run MyApp::Example1
>> end
>> map 'http://example2.com' do
>> run MyApp::Example2
>> end
> For example, if it was possible to read rack's SERVER_NAME in config.ru, I
> would do something like:
>> if SERVER_NAME == 'example1.com'
>> map '/' do
>> run MyApp::Example1
>> end
>> end
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Arman <arm... @gmail.com>
Date: Sat, 22 Sep 2012 03:32:30 -0700
Local: Sat, Sep 22 2012 6:32 am
Subject: Re: Possible to read request's host in config.ru?
Thanks for the quick answer. This definitely works.
Our of curiosity, is it possible to see the host and other request
information in config.ru?
On Sep 22, 2012 3:04 AM, "Magnus Holm" <judo... @gmail.com> wrote:
> It's already supported, you just need the trailing slash:
> map 'http://example1.com/' do
> run MyApp::Example1
> end
> // Magnus Holm
> On Sat, Sep 22, 2012 at 11:58 AM, armanx <arm... @gmail.com> wrote:
> > Is it possible to detect the incoming request's domain name (host) in
> > config.ru? I'm trying to use URLMap to map different domains to
> different
> > apps, all running on the same IP. Theoretically, I'm trying to achieve
> this
> > effect:
> >> map 'http://example1.com' do
> >> run MyApp::Example1
> >> end
> >> map 'http://example2.com' do
> >> run MyApp::Example2
> >> end
> > For example, if it was possible to read rack's SERVER_NAME in config.ru,
> I
> > would do something like:
> >> if SERVER_NAME == 'example1.com'
> >> map '/' do
> >> run MyApp::Example1
> >> end
> >> end
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Magnus Holm <judo... @gmail.com>
Date: Sat, 22 Sep 2012 12:42:11 +0200
Local: Sat, Sep 22 2012 6:42 am
Subject: Re: Possible to read request's host in config.ru?
No, but this is what middleware are for:
class ApplicationChooser
def initialize(apps)
@apps = apps
end
def call(env)
@apps.each do |proc, app|
return app.call(env) if proc.call(env)
end
end
run ApplicationChooser.new(
proc { |env| env["SERVER_NAME"] == "example.com" } => App1,
proc { |env| env["QUERY_STRING"] == "admin" } => App2,
proc { |env| true } => Default
)
// Magnus Holm
On Sat, Sep 22, 2012 at 12:32 PM, Arman <arm
... @gmail.com> wrote:
> Thanks for the quick answer. This definitely works.
> Our of curiosity, is it possible to see the host and other request
> information in config.ru?
> On Sep 22, 2012 3:04 AM, "Magnus Holm" <judo... @gmail.com> wrote:
>> It's already supported, you just need the trailing slash:
>> map 'http://example1.com/' do
>> run MyApp::Example1
>> end
>> // Magnus Holm
>> On Sat, Sep 22, 2012 at 11:58 AM, armanx <arm... @gmail.com> wrote:
>> > Is it possible to detect the incoming request's domain name (host) in
>> > config.ru? I'm trying to use URLMap to map different domains to
>> > different
>> > apps, all running on the same IP. Theoretically, I'm trying to achieve
>> > this
>> > effect:
>> >> map 'http://example1.com' do
>> >> run MyApp::Example1
>> >> end
>> >> map 'http://example2.com' do
>> >> run MyApp::Example2
>> >> end
>> > For example, if it was possible to read rack's SERVER_NAME in config.ru,
>> > I
>> > would do something like:
>> >> if SERVER_NAME == 'example1.com'
>> >> map '/' do
>> >> run MyApp::Example1
>> >> end
>> >> end
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
armanx <arm... @gmail.com>
Date: Mon, 24 Sep 2012 17:37:55 -0700 (PDT)
Local: Mon, Sep 24 2012 8:37 pm
Subject: Re: Possible to read request's host in config.ru?
Thank you so much for prompt and useful explanation.
On Saturday, September 22, 2012 3:42:32 AM UTC-7, Magnus Holm wrote:
> No, but this is what middleware are for:
> class ApplicationChooser > def initialize(apps) > @apps = apps > end
> def call(env) > @apps.each do |proc, app| > return app.call(env) if proc.call(env) > end > end
> run ApplicationChooser.new( > proc { |env| env["SERVER_NAME"] == "example.com" } => App1, > proc { |env| env["QUERY_STRING"] == "admin" } => App2, > proc { |env| true } => Default > )
> // Magnus Holm
> On Sat, Sep 22, 2012 at 12:32 PM, Arman <arm... @gmail.com <javascript:>> > wrote: > > Thanks for the quick answer. This definitely works.
> > Our of curiosity, is it possible to see the host and other request > > information in config.ru?
> > On Sep 22, 2012 3:04 AM, "Magnus Holm" <jud... @gmail.com <javascript:>> > wrote:
> >> It's already supported, you just need the trailing slash:
> >> map 'http://example1.com/' do > >> run MyApp::Example1 > >> end
> >> // Magnus Holm
> >> On Sat, Sep 22, 2012 at 11:58 AM, armanx <arm... @gmail.com<javascript:>> > wrote: > >> > Is it possible to detect the incoming request's domain name (host) in > >> > config.ru? I'm trying to use URLMap to map different domains to > >> > different > >> > apps, all running on the same IP. Theoretically, I'm trying to > achieve > >> > this > >> > effect:
> >> >> map 'http://example1.com' do > >> >> run MyApp::Example1 > >> >> end
> >> >> map 'http://example2.com' do > >> >> run MyApp::Example2 > >> >> end
> >> > For example, if it was possible to read rack's SERVER_NAME in > config.ru, > >> > I > >> > would do something like:
> >> >> if SERVER_NAME == 'example1.com' > >> >> map '/' do > >> >> run MyApp::Example1 > >> >> end > >> >> end
You must
Sign in before you can post messages.
You do not have the permission required to post.