| Class | Grape::API::Instance |
| In: |
lib/grape/api/instance.rb
|
| Parent: | Object |
The API Instance class, is the engine behind Grape::API. Each class that inherits from this will represent a different API instance
| LOCK | = | Mutex.new | A class-level lock to ensure the API is not compiled by multiple threads simultaneously within the same process. |
| base | [R] | |
| configuration | [RW] | |
| instance | [R] | |
| router | [R] |
This is the interface point between Rack and Grape; it accepts a request from Rack and ultimately returns an array of three values: the status, the headers, and the body. See [the rack specification] (www.rubydoc.info/github/rack/rack/master/file/SPEC) for more.
Builds the routes from the defined endpoints, effectively compiling this API into a usable form.
Execute first the provided block, then each of the block passed in. Allows for simple ‘before’ setups of settings stack pushes.
Some requests may return a HTTP 404 error if grape cannot find a matching route. In this case, Grape::Router adds a X-Cascade header to the response and sets it to ‘pass’, indicating to grape‘s parents they should keep looking for a matching route on other resources.
In some applications (e.g. mounting grape on rails), one might need to trap errors from reaching upstream. This is effectivelly done by unsetting X-Cascade. Default :cascade is true.