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: Using Rack Middlware to filter parameters
Date: Thu, 5 Nov 2009 23:32:39 +0100	[thread overview]
Message-ID: <200911052332.39227.ibc@aliax.net> (raw)
In-Reply-To: <50c7f5da-ba10-4552-9e19-64cf8ede1211@k17g2000yqb.googlegroups.com>


El Jueves, 5 de Noviembre de 2009, RobL escribió:
> 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.

> 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.

Do you mean parameters in the request URI? or in the body? in the first case 
the content-length should not be modified.

 
> 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.

I expect that Rack is not designed for that, as changing the request is not a 
very common usage (IMHO).

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

  reply	other threads:[~2009-11-05 22:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-05 11:02 Using Rack Middlware to filter parameters RobL
2009-11-05 22:32 ` Iñaki Baz Castillo [this message]
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=200911052332.39227.ibc@aliax.net \
    --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).