Optionsful
Provide HTTP OPTIONS support for the Ruby on Rails framework.
- Note for the impatient: installation instructions below.
- Note for the dummies: change host names and paths properly.
- Note for the unfaithful: run
rake routes
to validate the results.
“-No! No! No! -Show me the code!”
Retrieving an HTTP OPTIONS request via telnet:
$ telnet localhost 3000
OPTIONS /posts HTTP/1.1
Host: http://localhost:3000
HTTP/1.1 204 No Content
Allow: GET, POST
Connection: close
Date: Thu, 22 Jul 2010 17:20:27 GMT
Link: "<http://localhost:3000/optionsful/posts>; type=text/html; rel=help"
OPTIONS /posts/1 HTTP/1.1
Host: http://localhost:3000
HTTP/1.1 204 No Content
Allow: GET, PUT, DELETE
Connection: close
Date: Thu, 22 Jul 2010 18:14:24 GMT
Link: "<http://localhost:3000/optionsful/posts/1/>; type=text/html; rel=help"
OPTIONS /posts/1/comments HTTP/1.1
Host: http://localhost:3000
HTTP/1.1 204 No Content
Allow: GET, POST
Connection: close
Date: Thu, 22 Jul 2010 18:12:43 GMT
Link: "<http://localhost:3000/optionsful/posts/1/comments>; type=text/html; rel=help"
Note the empty line which is part of the HTTP protocol.
Telnet is the geek way. You would like better to use an HTTP client software. I use HTTP Client on Mac OS X.
INSTALLATION:
- Change directory to your Ruby on Rails web application,
- Add gem dependency to
config/environment.rb
:config.gem
- To install it, run
rake gems:install
or:$ gem install optionsful
- Enjoy! And give feedback! :)
Link header WARNING
To enable the Link URI on your application, check the Wisdomful project!
Link base path (Note: Work in Progress)
- To change the generated URI base path, install and edit the configuration file:
- run
rake optionsful:yml
- edit the ‘optionsful.yml’ file at your application’s ‘config’ folder.
- run
- Example:
development: http: base_path: /blopts
- Note:
Allow
andLink
are expected headers on a response to an HTTP OPTIONS request. I will think about some features to add more flexibility on theLink
generation pretty soon.
KNOWN ISSUES
- Rails route recognition still need some work
- Platform: ruby 1.8.7, rails 2.3.8, rack 1.2.1
Get involved
- Mailing list: http://groups.google.com/group/optionsful
- Bug tracker : http://kayaman.lighthouseapp.com/projects/56438-optionsful/overview
CONTRIBUTORS
- Me, myself and I, so far.
- You are welcome, do it. ;-)
Copyright © 2010 Marco Antonio Gonzalez Junior, [email protected], released under the MIT license.