Software /
code /
prosody
File
util/adhoc.lua @ 11106:76f46c2579a2 0.11
net.websocket.frames: Allow all methods to work on non-string objects
Instead of using the string library, use methods from the passed object,
which are assumed to be equivalent.
This provides compatibility with objects from util.ringbuffer and
util.dbuffer, for example.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 17 Sep 2020 13:00:19 +0100 |
parent | 8382:e5d00bf4a4d5 |
child | 10667:49312378ba1d |
line wrap: on
line source
-- luacheck: ignore 212/self local function new_simple_form(form, result_handler) return function(self, data, state) if state then if data.action == "cancel" then return { status = "canceled" }; end local fields, err = form:data(data.form); return result_handler(fields, err, data); else return { status = "executing", actions = {"next", "complete", default = "complete"}, form = form }, "executing"; end end end local function new_initial_data_form(form, initial_data, result_handler) return function(self, data, state) if state then if data.action == "cancel" then return { status = "canceled" }; end local fields, err = form:data(data.form); return result_handler(fields, err, data); else return { status = "executing", actions = {"next", "complete", default = "complete"}, form = { layout = form, values = initial_data(data) } }, "executing"; end end end return { new_simple_form = new_simple_form, new_initial_data_form = new_initial_data_form };