Class: Faraday::Response::OSDumper

Inherits:
Middleware
  • Object
show all
Defined in:
lib/yao/faraday_middlewares.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/yao/faraday_middlewares.rb', line 68

def on_complete(env)
  require 'pp'

  body = if env.response_headers["content-type"] == "application/json"
           JSON.parse(env.body)
         else
           env.body
         end

  params = [
    env.url.to_s,
    body,
    env.request_headers,
    env.response_headers,
    env.method,
    env.status
  ].map(&:pretty_inspect)
  $stdout.puts("================================\n OpenStack response inspection:\n================================\nRequested To: %s\n\nBody:\n%s\nRequest Headers:\n%s\nResponse Headers:\n%s\n\nMethod: %s\nStatus Code: %s\n================================\n\n  FMT\nend\n" % params)