Sha256: 269ed468a805bfb2a3d5c4c71d133ea90fe5fd68ee29c324007d68f206227890
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
module HttpStore module Middleware class RequestLog include HttpStore::Helpers::Storable STRING_LIMIT_SIZE = 30_000 def initialize(app) @app = app end def call(env) status, headers, body = @app.call(env) [status, headers, body] ensure build_meta(env, status, headers, body) store_request(false) end def build_meta(env, status, headers, body) request = ActionDispatch::Request.new(env) @meta = Hashie::Mash.new(format_req(request)) @meta.merge!(format_rsp(status, headers, body)) end def format_req(request) { url: request.url, path: request.path, http_method: request.request_method, data: request.params, client_type: request.params[:client_type], is_system: true, headers: request.headers.select { |k, _v| k.start_with? 'HTTP_' }.to_h, query_params: request.query_parameters, force: true, } end def format_rsp(status, headers, body) { status_code: status, response_headers: headers, response: body.try(:body) || body } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
http_store-0.6.17 | lib/http_store/middleware/request_log.rb |
http_store-0.6.16 | lib/http_store/middleware/request_log.rb |
http_store-0.6.15 | lib/http_store/middleware/request_log.rb |