Skip to content

Commit c5f0515

Browse files
committed
Update readme about registering middleware in custom Rails applications
1 parent a20bcb1 commit c5f0515

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3642,6 +3642,14 @@ You can access the controller params, headers, and helpers through the context w
36423642
Note that when you're using Grape mounted on Rails you don't have to use Rails middleware because it's already included into your middleware stack.
36433643
You only have to implement the helpers to access the specific `env` variable.
36443644

3645+
If you are using a custom application that is inherited from `Rails::Application` and need to insert a new middleware among the ones initiated via Rails, you will need to register it manually in your custom application class.
3646+
3647+
```ruby
3648+
class Company::Application < Rails::Application
3649+
config.middleware.insert_before(Rack::Attack, Middleware::ApiLogger)
3650+
end
3651+
```
3652+
36453653
### Remote IP
36463654

36473655
By default you can access remote IP with `request.ip`. This is the remote IP address implemented by Rack. Sometimes it is desirable to get the remote IP [Rails-style](http://stackoverflow.com/questions/10997005/whats-the-difference-between-request-remote-ip-and-request-ip-in-rails) with `ActionDispatch::RemoteIp`.

0 commit comments

Comments
 (0)