Skip to content
forked from madx/roy

A tiny module that aims to provide a REST-like interface to any Ruby object, optimized for the Creator Console-server

License

Notifications You must be signed in to change notification settings

buffpojken/rackable

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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, ...

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)

You can issue a redirect using the provided redirect method. It take the url to redirect to. If no url is provided, an empty 302 is returned.

About

A tiny module that aims to provide a REST-like interface to any Ruby object, optimized for the Creator Console-server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%