diff options
Diffstat (limited to 'lib/chef_zero/rest_router.rb')
-rw-r--r-- | lib/chef_zero/rest_router.rb | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/lib/chef_zero/rest_router.rb b/lib/chef_zero/rest_router.rb index a93af8b..2b5e129 100644 --- a/lib/chef_zero/rest_router.rb +++ b/lib/chef_zero/rest_router.rb @@ -1,4 +1,4 @@ -require 'pp' +require "pp" module ChefZero class RestRouter @@ -33,40 +33,40 @@ module ChefZero private - def find_endpoint(clean_path) - _, endpoint = routes.find { |route, endpoint| route.match(clean_path) } - endpoint || not_found - end + def find_endpoint(clean_path) + _, endpoint = routes.find { |route, endpoint| route.match(clean_path) } + endpoint || not_found + end - def log_request(request) - ChefZero::Log.debug do - "#{request.method} /#{request.rest_path.join("/")}".tap do |msg| - next unless request.method =~ /^(POST|PUT)$/ + def log_request(request) + ChefZero::Log.debug do + "#{request.method} /#{request.rest_path.join("/")}".tap do |msg| + next unless request.method =~ /^(POST|PUT)$/ - if request.body.nil? || request.body.empty? - msg << " (no body)" - else - msg << [ - "", - "--- #{request.method} BODY ---", - request.body.chomp, - "--- END #{request.method} BODY ---" - ].join("\n") - end + if request.body.nil? || request.body.empty? + msg << " (no body)" + else + msg << [ + "", + "--- #{request.method} BODY ---", + request.body.chomp, + "--- END #{request.method} BODY ---", + ].join("\n") end end - - ChefZero::Log.debug { request.pretty_inspect } end - def log_response(response) - ChefZero::Log.debug { - [ "", - "--- RESPONSE (#{response[0]}) ---", - response[2].chomp, - "--- END RESPONSE ---", - ].join("\n") - } - end + ChefZero::Log.debug { request.pretty_inspect } + end + + def log_response(response) + ChefZero::Log.debug { + [ "", + "--- RESPONSE (#{response[0]}) ---", + response[2].chomp, + "--- END RESPONSE ---", + ].join("\n") + } + end end end |