Currently, the json and csv exports are just named `data` which is not
intuitive. This adds proper file name extensions using the
Content-disposition HTTP header.
Suggested-by: Ameer Dawood <ameer1234567890@gmail.com>
[slightly reword commit message, squash commits]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
json = "application/json"
}
+ local filename = "data." .. mtype
+
local args = { }
local mtype = http.formvalue("type") or "json"
local delim = http.formvalue("delim") or ";"
end
http.prepare_content(types[mtype])
+ http.header("Content-Disposition", "attachment; filename=\"%s\"" % filename)
exec("/usr/sbin/nlbw", args, http.write)
end