Mercurial Hosting > disearch
diff src/lib/Utils.luan @ 13:af2b95854072
add server records
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 30 Oct 2023 21:32:42 -0600 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib/Utils.luan Mon Oct 30 21:32:42 2023 -0600 @@ -0,0 +1,28 @@ +local Luan = require "luan:Luan.luan" +local error = Luan.error +local ipairs = Luan.ipairs or error() +local set_metatable = Luan.set_metatable or error() +local Http = require "luan:http/Http.luan" + + +local Utils = {} + +function Utils.get_user() + return Http.request.cookies.user +end + +local set_mt = {} +function set_mt.__index(table,key) + return false +end + +function Utils.list_to_set(list) + local set = {} + for _, v in ipairs(list) do + set[v] = true + end + set_metatable(set,set_mt) + return set +end + +return Utils