Class: AsanaExceptionNotifier::Request::Middleware
- Inherits:
-
Object
- Object
- AsanaExceptionNotifier::Request::Middleware
- Includes:
- ApplicationHelper
- Defined in:
- lib/asana_exception_notifier/request/middleware.rb
Overview
middleware used only in development for testing purpose
Instance Method Summary collapse
-
#request(client, head, body) ⇒ Array<Hash,String>
Method that is used to debug requests to API’s The method receives the request object and prints it content to console.
-
#response(resp) ⇒ EventMachine::HttpResponse
Method that is used to debug responses from API’s The method receives the response object and prints it content to console.
Methods included from ApplicationHelper
add_files_to_zip, compress_files, create_archive, create_upload_file_part, default_template_path, ensure_eventmachine_running, escape, execute_with_rescue, extract_body, file_upload_request_options, force_utf8_encoding, get_extension_and_name_from_file, get_hash_rows, get_multi_request_values, get_response_from_request, hash_to_html_attributes, link_helper, log_bactrace, log_exception, logger, max_length, mount_table, mount_table_for_hash, multi_request_manager, multipart_file_upload_details, parse_fieldset_value, permitted_options, register_em_error_handler, rescue_interrupt, root, run_em_reactor, set_fieldset_key, setup_em_options, show_hash_content, split_archive, tempfile_details, template_dir, template_path_exist
Instance Method Details
#request(client, head, body) ⇒ Array<Hash,String>
Method that is used to debug requests to API’s The method receives the request object and prints it content to console
14 15 16 17 18 19 20 21 22 |
# File 'lib/asana_exception_notifier/request/middleware.rb', line 14 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 |
#response(resp) ⇒ EventMachine::HttpResponse
Method that is used to debug responses from API’s The method receives the response object and prints it content to console
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/asana_exception_notifier/request/middleware.rb', line 29 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 |