Slide 32
Slide 32 text
Ϣʔεέʔε
ϩάهϛυϧΣΞ
class LoggingMiddleware
def initialize(app)
@app = app
end
def call(env)
ENV['ENABLE_LOGGING'] ? call_with_logging(env) : call_without_logging(env)
end
def call_with_logging(env)
request = Rack::Request.new env
status, headers, body = call_without_logging(env)
Log.create(request: request, response: [status, headers, body])
[status, headers, body]
end
def call_without_logging(env)
@app.call env
end
end