Skip to content

Instantly share code, notes, and snippets.

@oberhamsi
Created March 16, 2016 15:50
Show Gist options
  • Save oberhamsi/8eb7da0b7e4e04874c1e to your computer and use it in GitHub Desktop.
Save oberhamsi/8eb7da0b7e4e04874c1e to your computer and use it in GitHub Desktop.
--- apt-get install lua-cjson
local cjson = require "cjson"
local cjson2 = cjson.new()
math.randomseed(os.time())
local headers = {}
headers["Content-Type"] = "application/json"
local platforms = {'moz', 'gcm', 'invalid-platform'};
local text = "0123456789abcdefghijklmnopqrstuvwxyz"
local chars = {}
for i = 1, #text do
chars[i] = text:sub(i, i)
end
rndstring = function(len)
local str = ""
for i= 0,len do
str = str .. chars[math.random(#chars)]
end
return str
end
-- /subscribe/:channel
-- token, platform (moz, gcm)
request = function()
local token = rndstring(50)
local body = cjson.encode({
token = rndstring(50),
platform = platforms[math.random(#platforms)]
})
--
--- print (body)
return wrk.format('POST', '/api/subscribe/channelwahl', headers, body)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment