This presentation is on 'Grape', which is an opinionated micro-framework for creating REST-like APIs in Ruby. For details, visit
http://intridea.github.io/grape
17. Parameters
Request parameters are available through the ”params” hash object.
Parameters are automatically populated from the request body on POST and PUT for form input, JSON and XML content-types.
18. Declared
Grape allows you to access only the parameters that have been declared by your ’params’ block. It filters out the params that have been passed, but are not
allowed.
20. Routes
We can define requirements for your named route parameters using regular expressions on namespace or endpoint.
21. Raise Exception
We can abort the execution of an API method by raising errors with
We can also return JSON formatted objects by raising error! and passing a hash instead of a message.
22. Exception Handling
Grape can be told to rescue all exceptions and return them in the API format.
You can also rescue specific exceptions.
23. API Formats
If we do not specify any, Grape will support XML, JSON, BINARY, and TXT content-types. The default format is :txt
24. Advantages
1. Designed to run on rack or existing application frameworks such as Rails and Sinatra
2. It has built-in support for common conventions, including multiple formats, subdomain/prefix
restriction.
3. Versioning is very easy.
4. A lightweight framework which is loosely coupled with other application frameworks.