From: Marek VavruĊĦa Date: Wed, 21 Mar 2018 22:57:19 +0000 (-0700) Subject: http: allow loading custom endpoints to http X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fcc4436eeb6e5b076cd81f12a80b3d80aae11b29;p=thirdparty%2Fknot-resolver.git http: allow loading custom endpoints to http Previously the module was created on configuration time, so it wasn't possible to inject custom endpoints to the default interface. --- diff --git a/modules/http/http.lua b/modules/http/http.lua index f3c4e4936..f2fe506a8 100644 --- a/modules/http/http.lua +++ b/modules/http/http.lua @@ -380,7 +380,13 @@ function M.config(conf) error('[http] mmdblua library not found, please remove GeoIP configuration') end end - M.add_interface(conf) + + -- 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) end return M diff --git a/modules/http/http.test.lua b/modules/http/http.test.lua index e22024b9b..198dd0abf 100644 --- a/modules/http/http.test.lua +++ b/modules/http/http.test.lua @@ -5,17 +5,13 @@ 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 = endpoints, + endpoints = { ['/test'] = {'text/custom', function () return 'hello' end} }, } }