rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: "Iñaki Baz Castillo" <ibc@aliax.net>
To: rack-devel@googlegroups.com
Subject: Re: How to use common code in each "map"
Date: Thu, 10 Sep 2009 19:30:00 +0200	[thread overview]
Message-ID: <cc1f582e0909101030qfe3a65eqc5a8992d51d47382@mail.gmail.com> (raw)
In-Reply-To: <391a49da0909100956u4d0b32cex47dbf74e48560c12@mail.gmail.com>


2009/9/10 Magnus Holm <judofyr@gmail.com>:
>
> It is possible with a middleware:
>
> class Restricter
>  def initialize(app, headers = {})
>    @app = app
>    @headers = headers
>  end
>
>  def call(env)
>    @headers.each do |key, value|
>      unless env[key] == value
>        return [403, {}, ['Something']]
>      end
>    end
>
>    @app.call(env)
>  end
> end
>
> map "/service1" do
>  use Restricter, "SERVER_NAME" => "testing"
>  run App1
> end


Great!

I was trying to get it but couldn't do it. Thanks a lot.



-- 
Iñaki Baz Castillo
<ibc@aliax.net>

      reply	other threads:[~2009-09-10 17:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-10 15:53 How to use common code in each "map" Iñaki Baz Castillo
2009-09-10 16:56 ` Magnus Holm
2009-09-10 17:30   ` Iñaki Baz Castillo [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=cc1f582e0909101030qfe3a65eqc5a8992d51d47382@mail.gmail.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).