From: Marek VavrusÌŒa Date: Tue, 6 Mar 2018 22:29:45 +0000 (-0800) Subject: modules/http: allow passing server options to http configuration X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=111590ad20b971618a3819c7a927fedf4679f45d;p=thirdparty%2Fknot-resolver.git 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. --- diff --git a/modules/http/http.lua b/modules/http/http.lua index c0df94004..e4baf8fdd 100644 --- a/modules/http/http.lua +++ b/modules/http/http.lua @@ -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 diff --git a/modules/http/http.test.lua b/modules/http/http.test.lua index 198dd0abf..e22024b9b 100644 --- a/modules/http/http.test.lua +++ b/modules/http/http.test.lua @@ -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, } }