diff --git a/package/gluon-config-api-core/luasrc/lib/gluon/config-api/controller/controller.lua b/package/gluon-config-api-core/luasrc/lib/gluon/config-api/controller/controller.lua index 76d46f93..9c44153d 100644 --- a/package/gluon-config-api-core/luasrc/lib/gluon/config-api/controller/controller.lua +++ b/package/gluon-config-api-core/luasrc/lib/gluon/config-api/controller/controller.lua @@ -59,6 +59,15 @@ local function pump(src, snk) end end +local function json_response(http, obj) + local result = json.stringify(obj, true) + http:header('Content-Type', 'application/json; charset=utf-8') + -- Content-Length is needed, as the transfer encoding is not chunked for + -- http method OPTIONS. + http:header('Content-Length', tostring(#result)) + http:write(result..'\n') +end + local function get_request_body_as_json(http) local request_body = "" pump(http.input, function (data) @@ -93,15 +102,6 @@ local function verify_schema(schema, config) return res end -local function json_response(http, obj) - local result = json.stringify(obj, true) - http:header('Content-Type', 'application/json; charset=utf-8') - -- Content-Length is needed, as the transfer encoding is not chunked for - -- http method OPTIONS. - http:header('Content-Length', tostring(#result)) - http:write(result..'\n') -end - entry({"v1", "config"}, call(function(http, renderer) local parts = load_parts()