lib/nsisam/fake_server.rb in nsisam-0.6.2 vs lib/nsisam/fake_server.rb in nsisam-0.6.3
- old
+ new
@@ -15,11 +15,11 @@
put "/" do
content_type :json
incoming = JSON.parse(request.body.read)
key = generate_key
- storage[key] = incoming['value']
+ storage[key] = incoming['value'] unless incoming.has_key? 'expire'
{ key: key, checksum: "0" }.to_json
end
get "/" do
content_type :json
@@ -42,12 +42,17 @@
end
post "/" do
content_type :json
incoming = JSON.parse(request.body.read)
+ expire = incoming['expire']
key = incoming["key"]
return 404 unless storage.has_key?(key)
- storage[key] = incoming['value']
+ if incoming.has_key? 'expire'
+ storage.delete(key)
+ else
+ storage[key] = incoming['value']
+ end
{ key: key, checksum: 0 }.to_json
end
end
class FakeServerManager