From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.86.23.1 with SMTP id 1cs34478fgw; Thu, 10 Sep 2009 10:30:18 -0700 (PDT) Received-SPF: pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.224.125.78 as permitted sender) client-ip=10.224.125.78; Authentication-Results: mr.google.com; spf=pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.224.125.78 as permitted sender) smtp.mail=grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com; dkim=pass header.i=grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com Received: from mr.google.com ([10.224.125.78]) by 10.224.125.78 with SMTP id x14mr1493857qar.13.1252603817279 (num_hops = 1); Thu, 10 Sep 2009 10:30:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to :received:received:received:received-spf:received:mime-version :received:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding:reply-to:sender:precedence :x-google-loop:mailing-list:list-id:list-post:list-help :list-unsubscribe:x-beenthere-env:x-beenthere; bh=DoDkYPJ99ySsjWTbESplbdT5ucPcSyyxEyDG+Xzwhb0=; b=IJeQXoZ15OaNmB6nGPAD+0hrml7FhhPqLRfoMYjGhrydVSeI9wnl2PneVdi8WClvdK rRS6BZA5r4woFl6KW8OCKG9RtWURyE8fn6qB06cwkUk0+/R8EDhbyJWkemWf1Zy4EmvA BxXYWFtXX4lxS3fQtnmEmYNp5a/jwamNghegI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:received-spf:authentication-results :mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding:reply-to:sender:precedence :x-google-loop:mailing-list:list-id:list-post:list-help :list-unsubscribe:x-beenthere-env:x-beenthere; b=m8eTr7dDUG46j5DxJKLe1WN3x6tTDlEwVR+YFbOHbtpfqbX7j2i7UjpWhqgMVRNn89 yv2zTlEA3wFh6ZPjsu240xZWlm+sB/S19gkC8sRECLSc00dp4cTjWI40V5nyhzHc8Fpu u4hApvZ2dhfRDRT3W/+XxvcNL6yv1oTyuEm5k= Received: by 10.224.125.78 with SMTP id x14mr212432qar.13.1252603816951; Thu, 10 Sep 2009 10:30:16 -0700 (PDT) Received: by 10.176.208.3 with SMTP id f3gr1656yqg.0; Thu, 10 Sep 2009 10:30:03 -0700 (PDT) X-Sender: ibc@aliax.net X-Apparently-To: rack-devel@googlegroups.com Received: by 10.223.144.85 with SMTP id y21mr67897fau.4.1252603801523; Thu, 10 Sep 2009 10:30:01 -0700 (PDT) Received: by 10.223.144.85 with SMTP id y21mr67896fau.4.1252603801275; Thu, 10 Sep 2009 10:30:01 -0700 (PDT) Return-Path: Received: from mail-fx0-f216.google.com (mail-fx0-f216.google.com [209.85.220.216]) by gmr-mx.google.com with ESMTP id 3si139536fgg.6.2009.09.10.10.30.01; Thu, 10 Sep 2009 10:30:01 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.216 is neither permitted nor denied by best guess record for domain of ibc@aliax.net) client-ip=209.85.220.216; Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 209.85.220.216 is neither permitted nor denied by best guess record for domain of ibc@aliax.net) smtp.mail=ibc@aliax.net Received: by mail-fx0-f216.google.com with SMTP id 12so275956fxm.44 for ; Thu, 10 Sep 2009 10:30:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.5.87 with SMTP id 23mr1100622fau.87.1252603800936; Thu, 10 Sep 2009 10:30:00 -0700 (PDT) In-Reply-To: <391a49da0909100956u4d0b32cex47dbf74e48560c12@mail.gmail.com> References: <391a49da0909100956u4d0b32cex47dbf74e48560c12@mail.gmail.com> Date: Thu, 10 Sep 2009 19:30:00 +0200 Message-ID: Subject: Re: How to use common code in each "map" From: =?UTF-8?Q?I=C3=B1aki_Baz_Castillo?= To: rack-devel@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Reply-To: rack-devel@googlegroups.com Sender: rack-devel@googlegroups.com Precedence: bulk X-Google-Loop: groups Mailing-List: list rack-devel@googlegroups.com; contact rack-devel+owner@googlegroups.com List-Id: List-Post: List-Help: List-Unsubscribe: , X-BeenThere-Env: rack-devel@googlegroups.com X-BeenThere: rack-devel@googlegroups.com 2009/9/10 Magnus Holm : > > It is possible with a middleware: > > class Restricter > =C2=A0def initialize(app, headers =3D {}) > =C2=A0 =C2=A0@app =3D app > =C2=A0 =C2=A0@headers =3D headers > =C2=A0end > > =C2=A0def call(env) > =C2=A0 =C2=A0@headers.each do |key, value| > =C2=A0 =C2=A0 =C2=A0unless env[key] =3D=3D value > =C2=A0 =C2=A0 =C2=A0 =C2=A0return [403, {}, ['Something']] > =C2=A0 =C2=A0 =C2=A0end > =C2=A0 =C2=A0end > > =C2=A0 =C2=A0@app.call(env) > =C2=A0end > end > > map "/service1" do > =C2=A0use Restricter, "SERVER_NAME" =3D> "testing" > =C2=A0run App1 > end Great! I was trying to get it but couldn't do it. Thanks a lot. --=20 I=C3=B1aki Baz Castillo