class Proxy::Reports::Api
Constants
- EXTS
Public Instance Methods
check_content_type(format)
click to toggle source
# File lib/smart_proxy_reports/reports_api.rb, line 20 def check_content_type(format) request_type = request.env["CONTENT_TYPE"] if format == "puppet" log_halt(415, "Content type must be application/x-yaml, was: #{request_type}") unless request_type.start_with?("application/x-yaml") elsif format == "ansible" log_halt(415, "Content type must be application/json, was: #{request_type}") unless request_type.start_with?("application/json") else log_halt(415, "Unknown format: #{format}") end end
save_payload(input, format)
click to toggle source
# File lib/smart_proxy_reports/reports_api.rb, line 36 def save_payload(input, format) filename = File.join(Proxy::Reports::Plugin.settings.incoming_save_dir, "#{format}-#{Time.now.to_f}.#{EXTS[format.to_sym]}") File.open(filename, "w") { |f| f.write(input) } end