RESTRack is a Rack based MVC framework that makes it extremely easy to develop RESTful data services. It is inspired by Rails, and follows a few of its conventions. But it has no routes file, routing relationships are done through supplying custom code blocks to class methods such as 'has_relationship_to', 'has_mapped_relationships_to', 'has_direct_relationship_to', and 'has_direct_relationships_to'. RESTRack aims at being lightweight and easy to use. It will automatically render JSON and XML for the data structures you return in your actions (any structure parsable by the 'json' and 'xml-simple' gems, respectively). If you supply a view for a controller action, you do that using a builder file (view/<controller>/<action>.xml.builder). XML format requests will then render the view template with the builder gem, rather than generating XML with XmlSimple.
<sudo> gem install restrack
Why RESTRack when there is Rails?
Rails is a powerful tool for full web applications. RESTRack is targetted at making development of lightweight data services as easy as possible, while still giving you a performant and extensible framework. The primary goal of the framework was to add as little as possible to the framework to give the web developer a good application space for developing JSON or XML services.
- restrack generate service foo_bar - restrack generate controller baz - restrack server 3456
REST action method names
All default RESTful controller method names align with their Rails counterparts, with two additional actions being supported(*). # HTTP Verb: | GET | PUT | POST | DELETE # Collection URI (/widgets/): | index | replace | create | *drop # Element URI (/widgets/42): | show | update | *add | destroy
...yet to be done... === Logging/Logging Level === XML Serialization ==== With Builder ==== With XmlSimple @output = XmlSimple.xml_out(data, 'AttrPrefix' => true) === Inputs ==== GET params ==== POST data
Copyright © 2010 Chris St. John
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.