bsw/jbe@1309: function util.api_error(status_code, status_text, error_code, error_description) bsw/jbe@1309: slot.set_layout(nil, "application/json") bsw/jbe@1309: request.set_status(status_code, status_text) bsw/jbe@1309: if status_code == 401 then bsw/jbe@1309: request.add_header("WWW-Authenticate", "Bearer error=\"" .. error_code .. "\", error_description=\"" .. error_description .. "\"") bsw/jbe@1309: end bsw/jbe@1309: slot.put_into("data", json.export(json.object{ bsw/jbe@1309: error = error_code, bsw/jbe@1309: error_description = error_description bsw/jbe@1309: })) bsw/jbe@1309: return false bsw/jbe@1309: end