Project

raccept

0.0
No commit activity in last 3 years
No release in over 3 years
This middleware turns Ruby objects that are not acceptable Rack bodies into xml or json depending upon the accepts header.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

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"?>
<hash>
  <this>is a Hash</this>
</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 © 2009 Sam Schenkman-Moore. See LICENSE for details.