-- Lua script for wrk to POST products
wrk.method = "POST"
wrk.body = '{"name":"Benchmark Product","description":"Product created during benchmark","price":49.99,"category":"Test","stock_quantity":50}'
wrk.headers["Content-Type"] = "application/json"

-- Counter for unique product names
local counter = 0

request = function()
    counter = counter + 1
    local body = string.format('{"name":"Benchmark Product %d","description":"Product created during benchmark","price":%f,"category":"Test","stock_quantity":%d}',
        counter, 
        math.random(10, 1000) + math.random(),
        math.random(1, 100)
    )
    
    return wrk.format("POST", "/products", nil, body)
end