lib/sapience/extensions/grape/middleware/logging.rb in sapience-1.0.10 vs lib/sapience/extensions/grape/middleware/logging.rb in sapience-1.0.11

- old
+ new

@@ -37,11 +37,11 @@ def parameters # rubocop:disable AbcSize { method: request.request_method, request_path: request.path, - format: env["api.endpoint"].instance_variable_get(:@app).instance_variable_get(:@app).options[:format], + format: response_format, status: response.try(:status) || 404, class_name: env["api.endpoint"].options[:for].to_s, action: "index", host: request.host, ip: (request.env["HTTP_X_FORWARDED_FOR"] || request.env["REMOTE_ADDR"]), @@ -57,9 +57,19 @@ }, } end private + + def content_type + request.env.fetch("CONTENT_TYPE") do + request.env["CONTENT-TYPE"] + end + end + + def response_format + content_type.to_s.split("/").last + end def request @request ||= ::Rack::Request.new(env) end