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

new ljpack encode #109

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

tom2nonames
Copy link

No description provided.

@@ -47,6 +47,11 @@ function Response:json(data, empty_table_as_object)
self:_send(utils.json_encode(data, empty_table_as_object))
end

function Response:ljpack(data)
self:set_header('Content-Type', 'application/ljpack')
self:__send(utils.ljpack_encode(data))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's enough to call the already existing self:_send directly.

Comment on lines +119 to +123
function Response:__send(content)
ngx.status = self.http_status or 200
ngx.print(content)
end

Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

@@ -8,6 +8,7 @@ local sgsub = string.gsub
local smatch = string.match
local table_insert = table.insert
local json = require("cjson")
local st = require("string.buffer")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the new api string.buffer was introduced from OpenResty 1.12.4.1 onwards, it would be nice to have a fallback to be compatible with older versions of OpenResty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants