Sha256: 6fca77b979fbc7bb50e049a5d6ceb766f0c3b19c067b606c90d7f3202c338e9c

Contents?: true

Size: 898 Bytes

Versions: 2

Compression:

Stored size: 898 Bytes

Contents

module RestClient
  module Jogger
    class Response < Action
      def template
        Tilt::JbuilderTemplate.new(root.join('templates', 'response_logging_template.json.jbuilder'))
      end

      private

      def render_params(start, finish, id, opts)
        params = response_params(opts)
        super.merge(params)
      end

      def response_params(opts = {})
        response_headers = opts[:response].try(:headers) || {}
        response_body = opts[:response].try(:body).to_s.dup.force_encoding('UTF-8')
        {
          exception: opts[:exception],
          response_headers: filtered_headers(response_headers),
          response_body: filter(body: response_body, headers: response_headers),
          code: opts[:response].try(:code)
        }
      end

      def filtered_headers(headers = {})
        Filters::Headers.new(data: headers).filter
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rest-client-jogger-1.3.0 lib/rest_client/jogger/response.rb
rest-client-jogger-1.2.2 lib/rest_client/jogger/response.rb