rack-toolbar 0 rspec travis-ci ruby Rubygems

Provides an easy way to create Rack Middleware that injects things into the response body

2 years after


Allows you to create simple Rack Middleware that will insert HTML (or whatever!) into responses at specific points.

This gem was extracted from Rack::Insight.

Project Rack::Toolbar
gem name rack-toolbar
license MIT
expert support Get help on Codementor
download rank Total Downloads
version Gem Version
dependencies Dependency Status
code quality Code Climate
inline documenation Inline docs
continuous integration Build Status
test coverage Coverage Status
homepage on Github.com
documentation on Rdoc.info
live chat Join the chat at https://gitter.im/pboling/rack-toolbar
Spread ~♡ⓛⓞⓥⓔ♡~ on Coderbits, on Coderwall

NOTE: As it goes with all middleware that modifies the response, not compatible with Rails' streaming responses because it modifies the response.


Add this line to your application's Gemfile:

gem 'rack-toolbar'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rack-toolbar


If your app is delivering a response like:


Simple Setup

You want to inject something into the response!

Configure your app to use Rack::Toolbar

use Rack::Toolbar, {snippet: "<div>More Important!</div>", insertion_point: "<body>", insertion_method: :after}

The div specified will be injected :after the <body tag.

    <div>More Important!</div>

Easy Setup

You want to build a Middleware that will deliver a custom response based on whatever.

Create your middleware to inherit from Rack::Toolbar, and define a render method:

class CustomMiddleware < Rack::Toolbar
  def render

Configure your app to use your CustomMiddleware. You can still use the :insertion_* options, but :snippet will be ignored.

use CustomMiddleware, {insertion_point: "</head>", insertion_method: :before}


After checking out the repo, run bin/setup to install dependencies. Then, run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release to create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.


  1. Fork it ( https://github.com/[my-github-username]/destination_errors/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Make sure to add tests!
  6. Create a new Pull Request


See the Network View


Other projects which will allow you to build Middleware to inject stuff into responses:

Related Repositories



Debugging toolbar for Rack applications implemented as middleware ...



:money_with_wings: An opinionated CKEditor editor for Rails with flexible image ...



A collection of padrino templates and plugins ...



Debugging toolbar for Rack applications implemented as middleware ...



ruby Rack application for hosting your bookmarks or maintaining a link blog ...

Top Contributors



-   v0.1.4 zip tar
-   v0.1.3 zip tar
-   v0.1.2 zip tar
-   v0.1.1 zip tar
-   v0.1.0 zip tar