rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: Martin <martin.aumont@gmail.com>
To: rack-devel@googlegroups.com
Subject: Re: Using Rack Middlware to filter parameters
Date: Thu, 5 Nov 2009 18:24:41 -0500	[thread overview]
Message-ID: <104b9b200911051524k5074c1b1j7b9398fae579b0fc@mail.gmail.com> (raw)
In-Reply-To: <200911052332.39227.ibc@aliax.net>


An example of rack middleware that modifies the request:
http://github.com/mynyml/rack-abstract-format/blob/master/lib/rack/abstract_format.rb

On Thu, Nov 5, 2009 at 5:32 PM, Iñaki Baz Castillo <ibc@aliax.net> wrote:
>
> 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 23:25 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
2009-11-05 23:24   ` Martin [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=104b9b200911051524k5074c1b1j7b9398fae579b0fc@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).