Skip to content

Instantly share code, notes, and snippets.

@seikoudoku2000
Last active December 12, 2015 06:38
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 seikoudoku2000/4730122 to your computer and use it in GitHub Desktop.
Save seikoudoku2000/4730122 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
require 'json'
require 'msgpack'
require 'uri'
while line = STDIN.gets
line.chomp!
jsonParsed = JSON.parse(line)
uri = URI.parse(jsonParsed['path'])
if uri.query
params = uri.query.split("&")
for param in params do
splited = param.split("=")
if splited.length == 2
jsonParsed[splited[0]] = splited[1]
else
next
end
end
jsonParsed['path'] = uri.path
print MessagePack.pack(jsonParsed)
else
next
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment