From: RobL <contact@robl.me>
To: Rack Development <rack-devel@googlegroups.com>
Subject: Using Rack Middlware to filter parameters
Date: Thu, 5 Nov 2009 03:02:58 -0800 (PST) [thread overview]
Message-ID: <50c7f5da-ba10-4552-9e19-64cf8ede1211@k17g2000yqb.googlegroups.com> (raw)
Hi there,
I wanted to ask if anyone could point me in the direction of some code
examples where you can use Rack Middleware to filter incoming
parameters.
Of course the classic example of middleware that does not a lot is
module Rack
class Myfilter
def initialize(app)
@app = app
end
def call(env)
@app.call(env)
end
end
end
But as a very tivial example I want be able to do something like
module Rack
class Myfilter
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
request.params.delete('someparam')
# but at this point I want/need to modify env
@app.call(env)
end
end
end
I'm not sure how I'd then get the modified env back, do you have to
literally modify something like env['query_string'], also at this
point the content length would be different so I'd have to update that
also.
Most of the applications I've seen are an endpoint and an app in
itself than sitting in the middle of the incoming request, and I'm yet
to find an example of modifying the incoming params.
Any help on this would be greatly appreciated
All the best.
RobL
next reply other threads:[~2009-11-05 11:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-05 11:02 RobL [this message]
2009-11-05 22:32 ` Using Rack Middlware to filter parameters Iñaki Baz Castillo
2009-11-05 23:24 ` Martin
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=50c7f5da-ba10-4552-9e19-64cf8ede1211@k17g2000yqb.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).