Skip to content
This repository has been archived by the owner on Dec 3, 2018. It is now read-only.

eric1234/rack_replace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rack::Replace

Rack middleware which will perform a find/replace on the response body. This is basically a re-implementation of the following Rails code:

after_filter {|c| c.response.body.gsub 'foo', 'bar'}

The advantage of this module over the above code is:

  • It will work in any rack-compatible environment.

  • It is streaming friendly as it operates on each chunk given to rack.

Usage

use Rack::Replace, 'foo', 'bar'
use Rack::Replace 'HOST' {|env, match| env['HTTP_HOST']}

For more advanced uses see rack_image_size and rack_new_window.

Credit

This gem was developed by Eric Anderson (pixelwareinc.com).

About

Rack Middleware: Find and replace on response

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages