Last active
June 13, 2016 22:16
-
-
Save robmint/d4135f22edb2ee54bed74fde9d0a499f to your computer and use it in GitHub Desktop.
Parse RayGun raw json data into a curl command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w | |
require 'rubygems' | |
require 'json' | |
#local = "localhost:3000" | |
local = false | |
json = File.read(ARGV[0]) | |
obj = JSON.parse(json) | |
req = obj['request'] | |
req['headers']['Host'] = local if local | |
req['hostName'] = local if local | |
req['headers']['X-Forwarded_proto'] = "http" if local | |
headers = req['headers'].map{|k,v| " -H \"#{k}: #{v}\""}.join | |
url = "#{req['headers']['X-Forwarded_proto']}://#{req['hostName']}#{req['url']}" | |
curl = "curl -v #{headers} #{url} > /dev/null" | |
`echo '#{curl}' | pbcopy` | |
puts "The curl command has been copied to the clipboard" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment