Class: Relax2::Interceptors::PrintRequest
- Inherits:
-
Object
- Object
- Relax2::Interceptors::PrintRequest
- Defined in:
- lib/relax2/interceptors.rb
Instance Method Summary collapse
- #call(request, perform_request) ⇒ Object
-
#initialize(print_headers:, print_body:) ⇒ PrintRequest
constructor
A new instance of PrintRequest.
Constructor Details
#initialize(print_headers:, print_body:) ⇒ PrintRequest
Returns a new instance of PrintRequest.
6 7 8 9 |
# File 'lib/relax2/interceptors.rb', line 6 def initialize(print_headers:, print_body:) @print_headers = print_headers @print_body = print_body end |
Instance Method Details
#call(request, perform_request) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/relax2/interceptors.rb', line 11 def call(request, perform_request) lines = [] lines << "#{request.http_method} #{request.path}" if @print_headers request.headers.each do |name, value| lines << "#{name}: #{value}" end end if @print_body && request.body lines << '' lines << request.body end puts lines.join("\n") puts '' perform_request.call(request) end |