Skip to content

Commit

Permalink
Add docs for Rollbar::Middleware::Rack
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
Jon de Andres committed Dec 20, 2016
1 parent e6e29ab commit 75c55d3
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,31 @@ $ heroku config:add ROLLBAR_ACCESS_TOKEN=POST_SERVER_ITEM_ACCESS_TOKEN
That's all you need to use Rollbar with Rails.


### Sinatra

Initialize Rollbar with your access token somewhere during startup:

```ruby
Rollbar.configure do |config|
config.access_token = 'POST_SERVER_ITEM_ACCESS_TOKEN'
# other configuration settings
# ...
end
```

Then mount the middleware in your app, like:

```ruby
require 'rollbar/middleware/sinatra'

class MyApp < Sinatra::Base
use Rollbar::Middleware::Sinatra
# other middleware/etc
# ...
end
```


### Rack

Initialize Rollbar with your access token somewhere during startup:
Expand All @@ -77,28 +102,22 @@ end
<!-- RemoveNextIfProject -->
Be sure to replace ```POST_SERVER_ITEM_ACCESS_TOKEN``` with your project's ```post_server_item``` access token, which you can find in the Rollbar.com interface.

This monkey patches `Rack::Builder` to work with Rollbar automatically.

For more control, disable the monkey patch:
The gem monkey patches `Rack::Builder` so Rollbar reports will be sent automatically without any other action. If you prefer to disable the monkey patch apply this change to your config:

```ruby
Rollbar.configure do |config|
config.disable_monkey_patch = true
config.disable_rack_monkey_patch = true
# other configuration settings
# ...
end
```

Then mount the middleware in your app, like:
If you disabled the `Rack::Builder` monkey patch or it doesn't work for the Rack framework you are using, then add our Rack middleware to your app:

```ruby
require 'rollbar/middleware/sinatra'
require 'rollbar/middleware/rack
class MyApp < Sinatra::Base
use Rollbar::Middleware::Sinatra
# other middleware/etc
# ...
end
use Rollbar::Middleware::Rack
```
### Plain Ruby
Expand Down Expand Up @@ -371,6 +390,8 @@ end
# You can add the middleware to your application, for example:
require 'rollbar/middleware/sinatra'
class App < Sinatra::Base
use Rollbar::Middleware::Sinatra
use RollbarPersonData
Expand Down

0 comments on commit 75c55d3

Please sign in to comment.