Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(api): export yaml with string.buffer #11706

Merged
merged 3 commits into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions kong/api/routes/config.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local buffer = require("string.buffer")
local declarative = require("kong.db.declarative")
local reports = require("kong.reports")
local errors = require("kong.db.errors")
Expand All @@ -6,7 +7,6 @@ local errors = require("kong.db.errors")
local kong = kong
local ngx = ngx
local type = type
local table = table
local tostring = tostring


Expand All @@ -27,14 +27,15 @@ end
local function truthy(val)
if type(val) == "string" then
val = val:lower()

return val == "true"
or val == "1"
or val == "on"
or val == "yes"
end

return val == true
or val == 1
or val == "true"
or val == "1"
or val == "on"
or val == "yes"
end


Expand Down Expand Up @@ -93,9 +94,9 @@ return {
end

local file = {
buffer = {},
buf = buffer.new(),
write = function(self, str)
self.buffer[#self.buffer + 1] = str
self.buf:put(str)
end,
}

Expand All @@ -105,7 +106,7 @@ return {
return kong.response.exit(500, { message = "An unexpected error occurred" })
end

return kong.response.exit(200, { config = table.concat(file.buffer) })
return kong.response.exit(200, { config = file.buf:get() })
end,
POST = function(self, db)
if kong.db.strategy ~= "off" then
Expand Down