From: armanx <armanx@gmail.com>
To: rack-devel@googlegroups.com
Subject: Re: Possible to read request's host in config.ru?
Date: Mon, 24 Sep 2012 17:37:55 -0700 (PDT) [thread overview]
Message-ID: <e5b383ef-d203-4ef7-a54c-05d0880c9c25@googlegroups.com> (raw)
In-Reply-To: <CAJ367fcvZeH46tOWOh2PsY7HQvgjGJvWGJ8JHt=PxKxWFfmU1g@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2005 bytes --]
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
> >> >
> >> >
>
[-- Attachment #2: Type: text/html, Size: 3328 bytes --]
prev parent reply other threads:[~2012-09-25 0:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-22 9:58 Possible to read request's host in config.ru? armanx
2012-09-22 10:04 ` Magnus Holm
2012-09-22 10:32 ` Arman
2012-09-22 10:42 ` Magnus Holm
2012-09-25 0:37 ` armanx [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://groups.google.com/group/rack-devel
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e5b383ef-d203-4ef7-a54c-05d0880c9c25@googlegroups.com \
--to=rack-devel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).