]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daf: fix HTTP API endpoints to work with webmgmt interface
authorPetr Špaček <petr.spacek@nic.cz>
Tue, 31 Mar 2020 07:02:16 +0000 (09:02 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Thu, 2 Apr 2020 11:57:31 +0000 (13:57 +0200)
It is broken at least since 1223599d1cb8d92f1ebe7100e926b8fe44bee2f2,
i.e. 4.0.0.

modules/daf/daf.lua

index 59f7ba8a85aa8ebe4a44e631154f295366f45b5c..9b6696eeb5964107aa985977533784e6561f7e80 100644 (file)
@@ -137,9 +137,10 @@ local M = {
 
 -- @function Cleanup module
 function M.deinit()
-       if http and http.endpoints then
-               http.endpoints['/daf'] = nil
-               http.endpoints['/daf.js'] = nil
+       if http then
+               local endpoints = http.configs._builtin.webmgmt.endpoints
+               endpoints['/daf'] = nil
+               endpoints['/daf.js'] = nil
                http.snippets['/daf'] = nil
        end
 end
@@ -325,10 +326,16 @@ end
 
 -- @function Configure module
 function M.config()
-       if not http or not http.endpoints then return end
+       if not http then
+               if verbose() then
+                       log('[daf ] HTTP API unavailable because HTTP module is not loaded, use modules.load("daf > http")')
+               end
+               return
+       end
+       local endpoints = http.configs._builtin.webmgmt.endpoints
        -- Export API and data publisher
-       http.endpoints['/daf.js'] = http.page('daf.js', 'daf')
-       http.endpoints['/daf'] = {'application/json', api, publish}
+       endpoints['/daf.js'] = http.page('daf.js', 'daf')
+       endpoints['/daf'] = {'application/json', api, publish}
        -- Export snippet
        http.snippets['/daf'] = {'Application Firewall', [[
                <script type="text/javascript" src="daf.js"></script>