From: "Iñaki Baz Castillo" <ibc@aliax.net>
To: rack-devel@googlegroups.com
Subject: How to use common code in each "map"
Date: Thu, 10 Sep 2009 17:53:10 +0200 [thread overview]
Message-ID: <cc1f582e0909100853k5ce9a491u92747f05b3ae12c1@mail.gmail.com> (raw)
Hi, I'm trying to use common HTTP request validation code in each "map" block:
----------------------------------------------------------------------
Rack::Builder.new do
map "/" do
run Proc.new { |env| [ 404, {"Content-Type" => "text/plain"}, [""] ] }
end
map "/service1" do
___VALIDATION_CODE___
run MyApp1
end
map "/service2" do
___VALIDATION_CODE___
run MyApp2
end
end
----------------------------------------------------------------------
Unfortunatelly I don't know how to fill ___VALIDATION_CODE___.
There I want to inspect env["SERVER_NAME"] and some other headers. In
case the validation is not passed, it should, *by itself*, return 403
code and MyApp1 or MyApp2 execution shouldn't take place.
IMHO it means that it cannot be done with a middleware since it would
execute MyApp1 or MyApp2.
Which is the appropriate approach to achieve it? Thanks for any help. Regards.
--
Iñaki Baz Castillo
<ibc@aliax.net>
next reply other threads:[~2009-09-10 15:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-10 15:53 Iñaki Baz Castillo [this message]
2009-09-10 16:56 ` How to use common code in each "map" Magnus Holm
2009-09-10 17:30 ` Iñaki Baz Castillo
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=cc1f582e0909100853k5ce9a491u92747f05b3ae12c1@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).