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.
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
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,
}
}