Skip to content

Commit 3d48a2f

Browse files
authored
Create grape integration documentation.
1 parent bcf3358 commit 3d48a2f

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

docs/howto/grape_integration.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
The AMS grape formatter relies on the existence of `env['grape.request']` which is implemeted by `Grape::Middleware::Globals`. You can meet his dependency by calling it before mounting the endpoints.
2+
3+
In the simpliest way:
4+
5+
```
6+
class API < Grape::API
7+
# @note Make sure this is above you're first +mount+
8+
use Grape::Middleware::Globals
9+
end
10+
```
11+
12+
or more like what is shown in current Grape tutorials:
13+
14+
```
15+
module MyApi
16+
class ApiBase < Grape::API
17+
use Grape::Middleware::Globals
18+
19+
require 'grape/active_model_serializers'
20+
include Grape::ActiveModelSerializers
21+
22+
mount MyApi::V1::ApiBase
23+
end
24+
end
25+
```
26+
27+
You could meet this dependency with your own middleware. The invocation might look like:
28+
29+
```
30+
module MyApi
31+
class ApiBase < Grape::API
32+
use My::Middleware::Thingamabob
33+
34+
require 'grape/active_model_serializers'
35+
include Grape::ActiveModelSerializers
36+
37+
mount MyApi::V1::ApiBase
38+
end
39+
end
40+
```

0 commit comments

Comments
 (0)