Sha256: fe103afecae0e46306fc13aaa843c784ff4e29904b1856517f301c3e216e0ec6
Contents?: true
Size: 570 Bytes
Versions: 10
Compression:
Stored size: 570 Bytes
Contents
module Fakeit module Middleware class Recorder def initialize(app) @app = app end def call(env) env .tap(&method(:log_request)) .then { @app.call(_1) } .tap(&method(:log_response)) end private def log_request(env) env['rack.input'] &.tap { |body| Logger.info("Request body: #{body.read}") } &.tap { |body| body.rewind } end def log_response(response) Logger.info("Response body: #{response[2].first}") end end end end
Version data entries
10 entries across 10 versions & 1 rubygems