Skip to content

Instantly share code, notes, and snippets.

@robmint
Last active June 13, 2016 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robmint/d4135f22edb2ee54bed74fde9d0a499f to your computer and use it in GitHub Desktop.
Save robmint/d4135f22edb2ee54bed74fde9d0a499f to your computer and use it in GitHub Desktop.
Parse RayGun raw json data into a curl command
#!/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