Reverse ERB Proxy

Get Version


→ ‘reverb’


Reverb is an ERB aware reverse proxy to integrate distributed applications using a simple plugin API.


sudo gem install reverb

The basics

Http proxy for integrating distributed applications via ERB templates and plugins.

The payload should be a typical Http response with the following properties:

The http header defines page level properties such as:
Header Property
X-Reverb-Title Title
X-Reverb-Description Meta description
X-Reverb-Keywords Meta keyword
X-Reverb-Styles CSS styles (comma separated list)
X-Reverb-Javascripts Javascripts (comma separated list)
X-Reverb-Template Template

If the content type is text/x-ruby-source then the body is eval’ed with the reverb (plugin) context.

Plugins are easy to write and follow the Capistrano plugin model (see more on Plugins below).

Demonstration of usage

With HTTP header:

X-Reverb-Enable: 1
X-Reverb-Template: default
X-Reverb-Title: The title
X-Reverb-Description: This is the description
X-Reverb-Keywords: keyword1,keyword2
X-Reverb-Styles: /foo/bars.css,/baz/boom.css
X-Reverb-Javascript: /foo/bar.js,/baz/boom.js

Content-Type: text/x-ruby-source

And HTTP body:

<h1>Test body</h1>
<p>The page title is '<%= page.title %>'</p>

With provided template:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">
  <title><%= page.title %></title>
  <meta name="description" content="<%= page.description %>" />
  <meta name="keywords" content="<%= page.keywords %>" />
  <%= page.styles %>  
  <%= page.body %>  
  <%= page.scripts %>  

Gets evaluated to:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">
  <title>The title</title>
  <meta name="description" content="This is the description" />
  <meta name="keywords" content="keyword1,keyword2" />
   <link type="text/css" rel="stylesheet" href="/foo/bar.css"/> 
 <link type="text/css" rel="stylesheet" href="/baz/boom.css"/> 
<h1>Test body</h1>
<p>The page title is 'The title'</p>

The page plugin gives you access to markup for scripts, styles, title, and any other information provided by the http headers.


Plugins are just modules installed with a namespace:

module MyPlugin

  def analytics(account_id)
    "<!-- provide analytics js here -->"

Reverb.plugin :my, MyPlugin

Now you can use this in your erb template.

<h1>Test body</h1>
<p>Putting analytics in: <%="UA-1989388-1") %></p>


How to submit patches

Read the 8 steps for fixing other people’s code and for section 8b: Submit patch to Google Groups, use the Google Group above.

The trunk repository is awaiting approval.


This code is free to use under the terms of the MIT license.


Comments are welcome via the forum

9th April 2008
Theme extended from Paul Battley