Skip to content

Instantly share code, notes, and snippets.

@phoet
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phoet/8970223 to your computer and use it in GitHub Desktop.
Save phoet/8970223 to your computer and use it in GitHub Desktop.
bacon infused middleware
# application.rb
#
# config.middleware.use "BaconInfused"
class BaconInfused
def initialize(app)
@app = app
end
def call(env)
s, h, r = @app.call(env)
if r.content_type == 'text/html'
r.body = r.body.
gsub(/Hamburg/, 'BACON').
gsub(/src=('|")([^'|"]+).png('|")/, 'src="http://bit.ly/1maTrIt"')
end
[s, h, r]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment