2007/4/18, carmen <[EMAIL PROTECTED]>: > what is the cleanest way to do something for every request of a particular > type (Verb, and Content-Type header)? i'm trying to figure out if shipping a > custom camping.rb is avoidable, and if, how i should structure a patch > > > my app http://whats-your.name/yard/ uses exclusively JSON based messaging > between server and client. this means POST bodies are JSON, and not > querystring.. camping assumes: > > elsif @method == "post" > qs.merge!(C.qsp(@in.read)) > > if i patch to: > > elsif @method == "post" > case e.CONTENT_TYPE > when "application/x-www-form-urlencoded" > qs.merge!(C.qsp(@in.read)) > when "application/json" > @input = JSON.parse(@in.read)) > end > > theres two probs, 1) you now have to always make sure you send the > x-www-form-urlencoded header (weird browsers, or XHR requests might not), 2) > @input is overwritten by qs.dup, input isnt a query string! > > i tried using a custom verb, which works fine in firefox, but not > WebKit-QT4-Linux.. RFC 2616 does not specify a format for the data in a POST > body, and the overall function of the request is consistent with POST. > > what do i do? :)
Hi Carmen, to avoid patching Camping, I suggest you look into overriding the "service" method for the target controllers. You can do this in your main application module or by including a custom module in your controllers, as you prefer. Let me know if you need more hints. -- Cheers, zimbatm _______________________________________________ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list