Created
June 5, 2012 21:06
-
-
Save ajokela/2877935 to your computer and use it in GitHub Desktop.
Rack::Callbacks
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
class TimeZone | |
def initialize(default) | |
@default = default | |
end | |
def call(env) | |
env['rack.timezone'] = find_timezone(env) || @default | |
end | |
end | |
class CompressBody | |
def call(response) | |
status, headers, body = response | |
compressed_body = zip_body(body) | |
[status, headers, compressed_body] | |
end | |
end | |
app = Rack::Callbacks.new do | |
before TimeZone, "default" | |
run YourPrimaryRackApp.new | |
after CompressBody | |
end | |
run app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment