Giter Site home page Giter Site logo

rackable's Introduction

Rackable

Rackable is a tiny module that aims to make any Ruby object Rack-friendly and provide it with a REST-like interface.

Basically, what it does is providing an object with a call() method that uses the Rack environement to dispatch to a method, giving helper objects such as headers, query parameters, ...

Specs

You can run the specs by running bacon on the rackable.rb file. Bacon is available at chneukirchen/bacon

Examples

Look in the examples/ folder.

Docs

Rackable provides a rack readable attribute which is a struct containing the following fields:

  • env: the parameter for call
  • response: a Rack::Response object that is returned by call
  • header: a hash of headers that is part of response
  • request: a Rack::Request created from the environement given to call
  • query: a hash of parameters extracted from the query string
  • data: a hash of parameters extracted from the request body (POST, PUT)

For both query and data, keys of the hash are symbols.

You can easily handle errors with the provided http_error method. It takes an error code and an optional message. If no message is given, the standard message from the HTTP Status Codes list will be used (eg. Not Found for 404)

rackable's People

Stargazers

François Vaux avatar Zhonghai Zuo avatar

Watchers

Zhonghai Zuo avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.