raccept 0

Rack middleware that converts Ruby objects into xml or json based on Accepts header

6 years after MIT

= Raccept (Rack Accepts Helper)

Converts Ruby objects to JSON or XML based on accepts headers.

Ignores legal Rack responses like "string" and ["string","string"]

== Install

gem install raccept

== Use

in config.ru

use Raccept run lambda {|env| [200,{"Content-Type" => "text/plain"}, {:this => 'is a Hash'} ] }

Will respond with ...

Accepts application/xml or text/xml

<?xml version="1.0" encoding="UTF-8"?>

is a Hash

Accepts application/json or text/json

{"this":"is a Hash"}

== Todo, maybe

  • Get something leaner than ActiveSupport for to_xml?
  • Support custom objects somehow?
  • Add tests for it.

== Copyright

Copyright (c) 2009 Sam Schenkman-Moore. See LICENSE for details.

Top Contributors