Created
June 20, 2013 04:53
-
-
Save gbuesing/5820386 to your computer and use it in GitHub Desktop.
Rack::AdHoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Allows you to write one-off middleware directly in config.ru. Good for prototyping. | |
# | |
# Example: | |
# | |
# use Rack::AdHoc do |app, env| | |
# status, headers, body = app.call(env) | |
# headers['X-Foo'] = 'bar' | |
# [status, headers, body] | |
# end | |
# | |
# run MyApp | |
# | |
class Rack::AdHoc | |
def initialize app, &block | |
@app = app | |
@block = block | |
end | |
def call env | |
@block.call @app, env | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment