From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.142.140.7 with SMTP id n7cs14540wfd; Thu, 5 Nov 2009 03:57:42 -0800 (PST) Return-Path: Received-SPF: pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.100.80.6 as permitted sender) client-ip=10.100.80.6; Authentication-Results: mr.google.com; spf=pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.100.80.6 as permitted sender) smtp.mail=grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com; dkim=pass header.i=grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com Received: from mr.google.com ([10.100.80.6]) by 10.100.80.6 with SMTP id d6mr1610790anb.25.1257422261125 (num_hops = 1); Thu, 05 Nov 2009 03:57:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to :mime-version:content-type:received:date:x-ip:user-agent :x-http-useragent:message-id:subject:from:to:x-google-approved :reply-to:sender:precedence:x-google-loop:mailing-list:list-id :list-post:list-help:list-unsubscribe:x-beenthere-env:x-beenthere; bh=WjiMWpBcyCONYGcLBoyAUOAXcKKz3E/6b9MqNOvX914=; b=zuGCcDA//wTwmvqouRSogNj2x1SG+DFYMr5/DN96ZiOH4zr5MXJ+GlOTCU2Ebt/L3R MhTmLtuDBSmTOa7e4ceXk7h6eTB8JJAaVcrjKneKt/4dAnMtO8J8PjborsZxJyxTSfg2 qlK4MPAOW8fHKWPgPrvneM0xoDPl7pDC8ntrY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:mime-version:content-type:date:x-ip :user-agent:x-http-useragent:message-id:subject:from:to :x-google-approved:reply-to:sender:precedence:x-google-loop :mailing-list:list-id:list-post:list-help:list-unsubscribe :x-beenthere-env:x-beenthere; b=xwv049YQL3A2M97dX4kJecSY9kQzELAzTsw6nLqpcNGN7AGvkaLOq+CP+wTBlf0t4h IakAE3uoz/SUD4Vqx59UfbCXTxj0lmc0Nk9ayT+O/efNOmBCkCWQcfWudpJeDNl9jVIs bFkXz5Ax/I4Y8lp2I1r/nbh3s8SmzLS3C7rUE= Received: by 10.100.80.6 with SMTP id d6mr158484anb.25.1257422261052; Thu, 05 Nov 2009 03:57:41 -0800 (PST) Received: by 10.176.181.37 with SMTP id d37gr1715yqf.0; Thu, 05 Nov 2009 03:57:39 -0800 (PST) X-Sender: contact@robl.me X-Apparently-To: rack-devel@googlegroups.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Received: by 10.150.20.3 with SMTP id 3mr136476ybt.57.1257418978881; Thu, 05 Nov 2009 03:02:58 -0800 (PST) Date: Thu, 5 Nov 2009 03:02:58 -0800 (PST) X-IP: 93.97.161.197 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.9.1.4) Gecko/20091028 Ubuntu/9.10 (karmic) Firefox/3.5.4,gzip(gfe),gzip(gfe) Message-ID: <50c7f5da-ba10-4552-9e19-64cf8ede1211@k17g2000yqb.googlegroups.com> Subject: Using Rack Middlware to filter parameters From: RobL To: Rack Development X-Google-Approved: kenneth.kalmer@gmail.com via web at 2009-11-05 11:57:38 Reply-To: rack-devel@googlegroups.com Sender: rack-devel@googlegroups.com Precedence: bulk X-Google-Loop: groups Mailing-List: list rack-devel@googlegroups.com; contact rack-devel+owner@googlegroups.com List-Id: List-Post: List-Help: List-Unsubscribe: , X-BeenThere-Env: rack-devel@googlegroups.com X-BeenThere: rack-devel@googlegroups.com 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