18 Apr 2007 05:58
customizing global request handler
carmen <_ <at> whats-your.name>
2007-04-18 03:58:22 GMT
2007-04-18 03:58:22 GMT
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 <at> method == "post" qs.merge!(C.qsp( <at> in.read)) if i patch to: elsif <at> method == "post" case e.CONTENT_TYPE when "application/x-www-form-urlencoded" qs.merge!(C.qsp( <at> in.read)) when "application/json" <at> input = JSON.parse( <at> 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) <at> 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? :)
RSS Feed