rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: misza222 <misza222@gmail.com>
To: Rack Development <rack-devel@googlegroups.com>
Subject: Re: Middleware to dispatch request to multiple applications based on request domain name
Date: Mon, 8 Feb 2010 13:17:07 -0800 (PST)	[thread overview]
Message-ID: <2ec41adb-c79e-45d1-bffd-8c5644dc0f43@a32g2000yqm.googlegroups.com> (raw)
In-Reply-To: <7D02B231-F5B0-4993-96B0-203882FC44AC@gmail.com>

On 8 Feb, 10:29, James Tucker <jftuc...@gmail.com> wrote:
> On 7 Feb 2010, at 22:36, misza222 wrote:
>
>
>
> > On 7 Feb, 11:57, James Tucker <jftuc...@gmail.com> wrote:
> >> On 6 Feb 2010, at 16:58, misza222 wrote:
>
> >>> Hi,
>
> >>> Here is a problem I have.
> >>> There is an app which consists of multiple subapps. Requests needs to
> >>> be dispatched to the particular subapp based on the domain name.
> >>> I thought Rack::URLMap may be a solution but couldn't make it to work
> >>> so eventually I created my own rack middleware that allowed me to
> >>> achieve it. Here is how it looks likehttp://github.com/misza222/dispatch_by_domain
> >>> But am I reinventing a wheel here? Is there any way to achieve the
> >>> same thing with existing rack middleware?
>
> >> map "http://mydomain.com/" do
> >>   run App1.new
> >> end
>
> >> map "http://otherdomain.com/" do
> >>   run App2.new
> >> end
>
> >>> Cheers,
>
> >>> Michal
>
> > Thanks James.
>
> > Where is 'map' method defined as I can't find it in the code?
>
> Rack::Builder in lib/rack/builder.rb
>
> > And is there any way to make one of those apps a default one so it can
> > catch all unmatched paths?
>
> Yes, don't use a host for that app, and map to /
>

That was my first guess too but unfortunately it doesn't work this
way.

map 'http://admin.localdomain/' do
  run AdminApp.new
end

map '/' do
  run DefaultApp.new
end

Always runs the default one.

>
>
> > --
> > Cheers,
>
> > Michal
>
>

      reply	other threads:[~2010-02-08 21:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-06 16:58 Middleware to dispatch request to multiple applications based on request domain name misza222
2010-02-07 11:57 ` James Tucker
2010-02-07 22:36   ` misza222
2010-02-07 22:54     ` Daniel N
2010-02-08 10:29     ` James Tucker
2010-02-08 21:17       ` misza222 [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=2ec41adb-c79e-45d1-bffd-8c5644dc0f43@a32g2000yqm.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).