Example #1
0
func (kvs *KvStoreModule) putjson(L *lua.LState) int {
	kv, err := kvs.kvStore.Put(L.ToString(1), string(luautil.ToJSON(L.CheckAny(2))), L.ToInt(3))
	if err != nil {
		panic(err)
	}
	L.Push(kvToTable(L, kv))
	return 1
}
Example #2
0
// Output JSON (with the right Content-Type), the data must be a table (or use `json` module with write).
func (resp *ResponseModule) jsonify(L *lua.LState) int {
	js := luautil.ToJSON(L.CheckAny(1))
	resp.body.Write(js)
	resp.headers["Content-Type"] = "application/json"
	return 0
}