Handling JSON POST bodies in your Ruby/Rack Application

Want to post largish JSON objects to your web service? Merely think that using POST parameters as a transport is a little ugly? If your web service is implemented as a Rack application, take a look at this handy Rack middleware: http://gist.github.com/981176. All it takes to use it with Sinatra is a simple use statement like the following and you can start posting JSON to your heart’s content.

[sourcecode language=”ruby”]
module Application
class AppServer < Sinatra::Base
use Rack::JsonPostBody
end
end
[/sourcecode]

Post a Comment