From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.141.43.5 with SMTP id v5cs114230rvj; Mon, 8 Feb 2010 13:59:05 -0800 (PST) Received-SPF: pass (google.com: domain of 3JolwSwgJCmsVRbiJlllPVJRU.LXVaJLT-MNeNUPXXPUNPaXdYb.LXV@groups.bounces.google.com designates 10.150.188.5 as permitted sender) client-ip=10.150.188.5; Authentication-Results: mr.google.com; spf=pass (google.com: domain of 3JolwSwgJCmsVRbiJlllPVJRU.LXVaJLT-MNeNUPXXPUNPaXdYb.LXV@groups.bounces.google.com designates 10.150.188.5 as permitted sender) smtp.mail=3JolwSwgJCmsVRbiJlllPVJRU.LXVaJLT-MNeNUPXXPUNPaXdYb.LXV@groups.bounces.google.com; dkim=pass header.i=3JolwSwgJCmsVRbiJlllPVJRU.LXVaJLT-MNeNUPXXPUNPaXdYb.LXV@groups.bounces.google.com Received: from mr.google.com ([10.150.188.5]) by 10.150.188.5 with SMTP id l5mr4711444ybf.81.1265666344049 (num_hops = 1); Mon, 08 Feb 2010 13:59:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:x-beenthere:received:received:received :received:received:received-spf:received:mime-version:received:date :in-reply-to:x-ip:references:user-agent:x-http-useragent:message-id :subject:from:to:reply-to:precedence:mailing-list:list-id:list-post :list-help:list-archive:x-thread-url:x-message-url:sender :list-subscribe:list-unsubscribe:content-type :content-transfer-encoding; bh=QU+GjlwP0qzQssUwqKvnBswh1hqoYG/HjM4mYx+8EOs=; b=nBS1d4aXAaoi3zPwR0UW8FMJvUSPDaQuz9eUSdYGbTOCXGm76YwrVG2Pj5RHlgIyqe nrgvjV7pifP4jYRt4ClARFYU1JXUejtenuU6gulJJiJ0NmmQBzeY4MOXE3bKgOpZkBgJ jCVkguRWcJ8utrEECJwgsrVogk9a9rOo/yH/o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:mime-version:date:in-reply-to:x-ip :references:user-agent:x-http-useragent:message-id:subject:from:to :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:x-thread-url:x-message-url:sender:list-subscribe :list-unsubscribe:content-type:content-transfer-encoding; b=48oqMaQShYnwna6dQ+e49x56gS7cZ5nz4F6IN+YVEairoyBdzM2HN6Xqm+5x4Ebc3T 2J5mrQ6XnSMUGZC+T63HNx7uWy3mfQNBYFshb7ESNMDFgDrEb3qboxONc7ttAEsihF9y s8z/UaoAiK8qCAGsB5ypAy1o3XNylCAz8BxVg= Received: by 10.150.188.5 with SMTP id l5mr305696ybf.81.1265666342675; Mon, 08 Feb 2010 13:59:02 -0800 (PST) X-BeenThere: rack-devel@googlegroups.com Received: by 10.150.4.27 with SMTP id 27ls786121ybd.2.p; Mon, 08 Feb 2010 13:59:01 -0800 (PST) Received: by 10.150.208.10 with SMTP id f10mr6800287ybg.9.1265666341358; Mon, 08 Feb 2010 13:59:01 -0800 (PST) Received: by 10.150.56.8 with SMTP id e8mr6758939yba.10.1265663827436; Mon, 08 Feb 2010 13:17:07 -0800 (PST) Received: by 10.150.56.8 with SMTP id e8mr6758937yba.10.1265663827413; Mon, 08 Feb 2010 13:17:07 -0800 (PST) Return-Path: Received: from mail-yx0-f151.google.com (mail-yx0-f151.google.com [209.85.210.151]) by gmr-mx.google.com with ESMTP id 18si574365ywh.9.2010.02.08.13.17.07; Mon, 08 Feb 2010 13:17:07 -0800 (PST) Received-SPF: pass (google.com: domain of misza222@gmail.com designates 209.85.210.151 as permitted sender) client-ip=209.85.210.151; Received: by yxe15 with SMTP id 15so20133631yxe.9 for ; Mon, 08 Feb 2010 13:17:07 -0800 (PST) MIME-Version: 1.0 Received: by 10.101.152.34 with SMTP id e34mr754657ano.59.1265663827350; Mon, 08 Feb 2010 13:17:07 -0800 (PST) Date: Mon, 8 Feb 2010 13:17:07 -0800 (PST) In-Reply-To: <7D02B231-F5B0-4993-96B0-203882FC44AC@gmail.com> X-IP: 82.71.41.52 References: <09F3BCD8-6945-4DCC-BA70-A7F1777DC09C@gmail.com> <09592190-728b-44a0-82ac-dda461bbc39e@z41g2000yqz.googlegroups.com> <7D02B231-F5B0-4993-96B0-203882FC44AC@gmail.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.9.0.17) Gecko/2010010604 Ubuntu/9.04 (jaunty) Firefox/3.0.17,gzip(gfe),gzip(gfe) Message-ID: <2ec41adb-c79e-45d1-bffd-8c5644dc0f43@a32g2000yqm.googlegroups.com> Subject: Re: Middleware to dispatch request to multiple applications based on request domain name From: misza222 To: Rack Development Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: X-Thread-Url: http://groups.google.com/group/rack-devel/t/82553516626086d8 X-Message-Url: http://groups.google.com/group/rack-devel/msg/8e46d9c7d5b64fc1 Sender: rack-devel@googlegroups.com List-Subscribe: , List-Unsubscribe: , Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 8 Feb, 10:29, James Tucker wrote: > On 7 Feb 2010, at 22:36, misza222 wrote: > > > > > On 7 Feb, 11:57, James Tucker 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/dispa= tch_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 > >> =A0 run App1.new > >> end > > >> map "http://otherdomain.com/" do > >> =A0 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 > >