Sha256: 53bf05594d9655e7471b6a2a0a226841495e77a601d66e1de37310c679972259
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
require 'appdash/event/base' module Appdash module Event # RackServer represents a HTTP event where a client's request was served via Rack. class RackServer < Base # @param [Rack::Request] req a Rack request object # @param [Rack::Response] resp an optional Rack response object # @param [Hash] attrs additional attributes, e.g. :user or :route def initialize(req, resp = nil, attrs = {}) server = attrs.dup server[:send] ||= Time.now server[:request] ||= {} server[:request].update parse_request(req) if resp server[:response] ||= {} server[:response].update parse_response(resp) end super("HTTPServer", server: server) end protected def parse_request(req) data = { method: req.request_method, path: req.fullpath, scheme: req.scheme, host: req.host, remote_ip: req.ip, content_length: req.content_length } [:content_type, :user_agent].each do |name| value = req.send(name) data[name] = value if value end data end def parse_response(resp) { content_length: resp.content_length, status_code: resp.status } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
appdash-0.6.3 | lib/appdash/event/rack_server.rb |
appdash-0.6.2 | lib/appdash/event/rack_server.rb |