Skip to content
Merged
Show file tree
Hide file tree
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
40 changes: 6 additions & 34 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,36 +1,8 @@
redefined = false
include_files = {"**/*.lua", "*.rockspec", "*.luacheckrc"}
exclude_files = {"lua_modules", ".luarocks", ".rocks", "luatest/luaunit.lua", "build"}
new_read_globals = {
'box',
'_TARANTOOL',
'tonumber64',
os = {
fields = {
'environ',
}
},
string = {
fields = {
'split',
'startswith',
},
},
table = {
fields = {
'maxn',
'copy',
'new',
'clear',
'move',
'foreach',
'sort',
'remove',
'foreachi',
'deepcopy',
'getn',
'concat',
'insert',
},
},
exclude_files = {
"lua_modules",
".luarocks",
".rocks",
"build",
"http/mime_types.lua",
}
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ _test: &test
- sudo apt-get -y update
- sudo apt-get install -y tarantool tarantool-dev
- tarantoolctl rocks make
- tarantoolctl rocks install luatest 0.2.2
script: .rocks/bin/luatest
- tarantoolctl rocks install luacheck 0.25.0
- tarantoolctl rocks install luatest 0.3.0
script:
- .rocks/bin/luacheck .
- .rocks/bin/luatest

_deploy: &deploy
provider: packagecloud
Expand Down
2 changes: 1 addition & 1 deletion examples/middleware.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local tsgi = require('http.tsgi')
local json = require('json')
local log = require('log')

box.cfg{} -- luacheck: ignore
box.cfg{}

local httpd = http_server.new('127.0.0.1', 12345, {
log_requests = true,
Expand Down
2 changes: 1 addition & 1 deletion http/router/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ local function catfile(...)
return
end

for i, pe in pairs(sp) do
for _, pe in pairs(sp) do
if path == nil then
path = pe
elseif string.match(path, '.$') ~= '/' then
Expand Down
2 changes: 1 addition & 1 deletion http/router/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ local function use_middleware(self, handler, opts)
before = '?string|table',
after = '?string|table',
})
local opts = table.deepcopy(opts)
opts = table.deepcopy(opts)
opts.handler = handler

local uuid = require('uuid')
Expand Down
16 changes: 8 additions & 8 deletions http/router/request.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ end

local function post_param(self, name)
local content_type = self:content_type()
if self:content_type() == 'multipart/form-data' then
if content_type == 'multipart/form-data' then
-- TODO: do that!
rawset(self, 'post_params', {})
elseif self:content_type() == 'application/json' then
elseif content_type == 'application/json' then
local params = self:json()
rawset(self, 'post_params', params)
elseif self:content_type() == 'application/x-www-form-urlencoded' then
elseif content_type == 'application/x-www-form-urlencoded' then
local params = lib.params(self:read_cached())
local pres = {}
for k, v in pairs(params) do
Expand Down Expand Up @@ -136,8 +136,8 @@ local function cookie(self, cookiename)
return nil
end

local function iterate(self, gen, param, state)
return setmetatable({ body = { gen = gen, param = param, state = state } },
local function iterate(_, gen, gen_param, state)
return setmetatable({ body = { gen = gen, param = gen_param, state = state } },
response.metatable)
end

Expand Down Expand Up @@ -168,12 +168,12 @@ end

local function request_json(req)
local data = req:read_cached()
local s, json = pcall(json.decode, data)
local s, json_data = pcall(json.decode, data)
if s then
return json
return json_data
else
error(utils.sprintf("Can't decode json in request '%s': %s",
data, tostring(json)))
data, tostring(json_data)))
return nil
end
end
Expand Down
7 changes: 3 additions & 4 deletions http/server/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ local errno = require('errno')

local DETACHED = 101

local ok, VERSION = pcall(require, 'http.VERSION')
if not ok then
VERSION = 'unknown'
local VERSION = 'unknown'
if package.search('http.VERSION') then
VERSION = require('http.VERSION')
end

---------
Expand Down Expand Up @@ -239,7 +239,6 @@ local function process_client(self, s, peer)
if not s:write(response) then
break
end
response = nil -- luacheck: ignore 311
-- Transfer-Encoding: chunked
for _, part in gen, param, state do
part = tostring(part)
Expand Down
Loading