Sha256: d143afda639c914b076014efd5fa4c4c6d4da15c8f8557545b9ecffa4911ebf2
Contents?: true
Size: 1.53 KB
Versions: 13
Compression:
Stored size: 1.53 KB
Contents
require_relative '../helpers/application_helper' module AsanaExceptionNotifier module Request # middleware used only in development for testing purpose class Middleware include AsanaExceptionNotifier::ApplicationHelper # Method that is used to debug requests to API's # The method receives the request object and prints it content to console # # @param [EventMachine::HttpRequest] client The Http request made to an API # @param [Hash] head The http headers sent to API # @param [String, nil] body The body sent to API # @return [Array<Hash,String>] Returns the http headers and the body def request(client, head, body) puts "############## HTTP REQUEST #####################\n" puts JSON.pretty_generate( headers: head, url: client.req.uri, body: force_utf8_encoding(body.to_s.inspect) ) [head, body] end # Method that is used to debug responses from API's # The method receives the response object and prints it content to console # # @param [EventMachine::HttpResponse] resp The Http response received from API # @return [EventMachine::HttpResponse] def response(resp) puts "############## HTTP RESPONSE #####################\n" headers = resp.response_header puts JSON.pretty_generate( headers: headers, status: headers.status, body: force_utf8_encoding(resp.response.to_s.inspect) ) resp end end end end
Version data entries
13 entries across 13 versions & 1 rubygems