comparison 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
comparison
equal deleted inserted replaced
12:3e2cb946d511 13:af2b95854072
1 local Luan = require "luan:Luan.luan"
2 local error = Luan.error
3 local ipairs = Luan.ipairs or error()
4 local set_metatable = Luan.set_metatable or error()
5 local Http = require "luan:http/Http.luan"
6
7
8 local Utils = {}
9
10 function Utils.get_user()
11 return Http.request.cookies.user
12 end
13
14 local set_mt = {}
15 function set_mt.__index(table,key)
16 return false
17 end
18
19 function Utils.list_to_set(list)
20 local set = {}
21 for _, v in ipairs(list) do
22 set[v] = true
23 end
24 set_metatable(set,set_mt)
25 return set
26 end
27
28 return Utils