Skip to content

Commit

Permalink
test: allow to set custom http server options
Browse files Browse the repository at this point in the history
Part of #137
  • Loading branch information
ligurio committed Oct 29, 2021
1 parent 442bb5f commit cba25ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions http/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,7 @@ local exports = {
internal = {
response_mt = response_mt,
request_mt = request_mt,
extend = extend,
}
}

Expand Down
9 changes: 6 additions & 3 deletions test/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ helpers.base_port = 12345
helpers.base_host = '127.0.0.1'
helpers.base_uri = ('http://%s:%s'):format(helpers.base_host, helpers.base_port)

helpers.cfgserv = function()
helpers.cfgserv = function(opts)
local path = os.getenv('LUA_SOURCE_DIR') or './'
path = fio.pathjoin(path, 'test')

local httpd = http_server.new(helpers.base_host, helpers.base_port, {
local opts = opts or {}
local opts = http_server.internal.extend({
app_dir = path,
log_requests = false,
log_errors = false
})
}, opts)

local httpd = http_server.new(helpers.base_host, helpers.base_port, opts)
:route({path = '/abc/:cde/:def', name = 'test'}, function() end)
:route({path = '/abc'}, function() end)
:route({path = '/ctxaction'}, 'module.controller#action')
Expand Down

0 comments on commit cba25ca

Please sign in to comment.