Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
28 lines (22 sloc) 0.632 kb
require "uuid"
require "logger"
module E20
module Ops
module Middleware
class TransactionIdMiddleware
def initialize(app, options = {})
@app = app
@uuid_generator = options[:uuid_generator] || UUID.method(:generate)
@logger = options[:logger] || Logger.new(STDOUT)
end
def call(env)
uuid = @uuid_generator.call.to_s
@logger.info "[#{self.class.name}] Transaction ID: #{uuid}"
status, headers, body = @app.call(env)
headers["X-Transaction"] = uuid
[status, headers, body]
end
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.