Sha256: 0e4a9f6048dea32ae83f6be658d198a33cbe8863691a9548777c71cc660feb97
Contents?: true
Size: 799 Bytes
Versions: 1
Compression:
Stored size: 799 Bytes
Contents
module LogMe class NetHttpFormatter def format_request(request, url) message = format_message(request) do message = with_line_break { "Request:" } message << with_line_break { "#{request.method} #{url}" } end end def format_response(response) message = format_message(response) do message = with_line_break { "Response:" } message << with_line_break { "HTTP/#{response.http_version} #{response.code} #{response.message}" } end end private def format_message(http) message = yield message << with_line_break { http.body } if has_body?(http) message end def with_line_break "#{yield}\n" end def has_body?(http) http.body && !http.body.strip.empty? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
log-me-0.0.8 | lib/logme/net_http_formatter.rb |