rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
* Using Rack Middlware to filter parameters
@ 2009-11-05 11:02 RobL
  2009-11-05 22:32 ` Iñaki Baz Castillo
  0 siblings, 1 reply; 3+ messages in thread
From: RobL @ 2009-11-05 11:02 UTC (permalink / raw)
  To: Rack Development


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-11-05 23:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).