Skip to content

Commit

Permalink
perf(api): export YAML with string.buffer (#11706)
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw authored Oct 12, 2023
1 parent 43861cc commit 425451c
Showing 1 changed file with 9 additions and 8 deletions.
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

1 comment on commit 425451c

@khcp-gha-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:425451cd451b08bf0c6a6828cd1d59afb6a114d6
Artifacts available https://github.com/Kong/kong/actions/runs/6497482269

Please sign in to comment.