Sha256: b7684cce40427e5d294b622bf1a4c12cbf77503ec5b921c9fa7968535d73e24f

Contents?: true

Size: 847 Bytes

Versions: 1

Compression:

Stored size: 847 Bytes

Contents

module RestMan
  class Request
    class LogRequest < ActiveMethod::Base

      def call
        return unless log

        out = []

        out << "RestMan.#{request.method} #{redacted_url.inspect}"
        out << payload.short_inspect if payload
        out << request.processed_headers.to_a.sort.map { |(k, v)| [k.inspect, v.inspect].join("=>") }.join(", ")
        log << out.join(', ') + "\n"
      end

      private

      def log
        request.log
      end

      def redacted_uri
        if uri.password
          sanitized_uri = uri.dup
          sanitized_uri.password = 'REDACTED'
          sanitized_uri
        else
          uri
        end
      end

      def redacted_url
        redacted_uri.to_s
      end

      def payload
        request.payload
      end

      def uri
        request.uri
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rest-man-1.1.0 lib/restman/request/log_request.rb