Commit 111590ad authored by Marek Vavruša's avatar Marek Vavruša Committed by Marek Vavruša

modules/http: allow passing server options to http configuration

This allows HTTP server to start with reuseport, reuseaddr or v6only.
The reuseport allows running HTTP module on all forks, not just the main one.
parent 906b8b82
......@@ -391,12 +391,7 @@ function M.config(conf)
end
end
-- Add endpoints to default endpoints
local endpoints = conf.endpoints or {}
for k, v in pairs(M.endpoints) do
endpoints[k] = v
end
M.interface(conf.host, conf.port, endpoints, conf.cert, conf.key)
M.add_interface(conf)
end
return M
......@@ -5,13 +5,17 @@ if not has_http then
done()
else
local request = require('http.request')
local endpoints = require('http').endpoints
-- custom endpoints
endpoints['/test'] = {'text/custom', function () return 'hello' end}
-- setup resolver
modules = {
http = {
port = 0, -- Select random port
cert = false,
endpoints = { ['/test'] = {'text/custom', function () return 'hello' end} },
endpoints = endpoints,
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment