blob: f4d5e7af443f5b43a788456c643a0ee8020de66e [file] [log] [blame]
Tim Duesterhus84ebc132020-05-19 13:49:41 +02001core.register_service("set_var", "http", function(applet)
2 local var_name = applet.headers["var"][0]
3 local result = applet:set_var(var_name, "value")
4 if result then
5 applet:set_status(202)
6 else
7 applet:set_status(400)
8 end
9 applet:add_header("echo", applet:get_var(var_name) or "(nil)")
10 applet:start_response()
11 applet:send("")
12end)
Tim Duesterhus4e172c92020-05-19 13:49:42 +020013
14core.register_service("set_var_ifexist", "http", function(applet)
15 local var_name = applet.headers["var"][0]
16 local result = applet:set_var(var_name, "value", true)
17 if result then
18 applet:set_status(202)
19 else
20 applet:set_status(400)
21 end
22 applet:add_header("echo", applet:get_var(var_name) or "(nil)")
23 applet:start_response()
24 applet:send("")
25end)