Created
January 17, 2017 02:20
-
-
Save yannick/0ec549870c34d66633209f6563080681 to your computer and use it in GitHub Desktop.
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
| class Gist | |
| def initialize | |
| @redis = H2O::Redis.new(:host => 'localhost', :port => 6379) | |
| end | |
| #ghetto parser | |
| def query_params(q) | |
| return Hash[q.split("&").map{|combo| combo.split("=") }] | |
| end | |
| def call(env) | |
| if env["REQUEST_METHOD"] == "POST" | |
| uuid = Time.now.to_i.to_s #fixme | |
| @redis.set(uuid, env["rack.input"].read).join | |
| ret = uuid | |
| elsif env["REQUEST_METHOD"] == "GET" | |
| qry = query_params(env["QUERY_STRING"]) | |
| ret = @redis.get(qry["id"]).join | |
| end | |
| [200, | |
| { | |
| "content-type" => "application/json", | |
| }, | |
| [ret] | |
| ] | |
| end | |
| end | |
| Gist.new | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment