lib/goliath/rack/formatters/html.rb in goliath-0.9.1 vs lib/goliath/rack/formatters/html.rb in goliath-0.9.2
- old
+ new
@@ -8,28 +8,12 @@
# as HTML escaped strings.
#
# @example
# use Goliath::Rack::Formatters::HTML
class HTML
- # Called by the framework to create the formatter.
- #
- # @param app The application
- # @return [Goliath::Rack::Formatters::HTML] The HTML formatter
- def initialize(app)
- @app = app
- end
+ include Goliath::Rack::AsyncMiddleware
- def call(env)
- async_cb = env['async.callback']
- env['async.callback'] = Proc.new do |status, headers, body|
- async_cb.call(post_process(status, headers, body))
- end
-
- status, headers, body = @app.call(env)
- post_process(status, headers, body)
- end
-
- def post_process(status, headers, body)
+ def post_process(env, status, headers, body)
body = [to_html(body, false)] if html_response?(headers)
[status, headers, body]
end
def html_response?(headers)