Skip to content

Commit

Permalink
use string.buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Sep 19, 2023
1 parent 03bfc29 commit 0eb1f41
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kong/plugins/grpc-gateway/deco.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- Copyright (c) Kong Inc. 2020

local cjson = require "cjson"
local buffer = require "string.buffer"
local pb = require "pb"
local grpc_tools = require "kong.tools.grpc"
local grpc_frame = grpc_tools.frame
Expand Down Expand Up @@ -285,19 +286,18 @@ end
function deco:downstream(chunk)
local body = (self.downstream_body or "") .. chunk

local out, n = {}, 1
local out = buffer.new()
local msg, body = grpc_unframe(body)

while msg do
msg = encode_json(pb.decode(self.endpoint.output_type, msg))

out[n] = msg
n = n + 1
out:put(msg)
msg, body = grpc_unframe(body)
end

self.downstream_body = body
chunk = table.concat(out)
chunk = out:get()

return chunk
end
Expand Down

0 comments on commit 0eb1f41

Please sign in to comment.