Skip to content

Commit

Permalink
Fix: Refactor backend server check in monitoring filter
Browse files Browse the repository at this point in the history
Restructure the logic to ensure server_host verification falls within the appropriate conditional block. This change optimizes the handling of server_host and improves readability. The refactor also corrects the indentation for better code clarity.

Signed-off-by: Christian Roessner <[email protected]>
  • Loading branch information
Christian Roessner committed Dec 9, 2024
1 parent a67369c commit 1b0ffd2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions server/lua-plugins.d/filters/monitoring.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,21 @@ function nauthilus_call_filter(request)
if expected_server and server_host ~= expected_server then
server_host = expected_server
end

attributes["Proxy-Host"] = server_host

nauthilus_builtin.custom_log_add(N .. "_backend_server", server_host)

backend_result:attributes(attributes)
nauthilus_backend.apply_backend_result(backend_result)
end
end

if server_host == nil then
nauthilus_builtin.custom_log_add(N .. "_backend_server", "failed")
nauthilus_builtin.status_message_set("No backend servers are available")
if server_host == nil then
nauthilus_builtin.custom_log_add(N .. "_backend_server", "failed")
nauthilus_builtin.status_message_set("No backend servers are available")

return nauthilus_builtin.FILTER_ACCEPT, nauthilus_builtin.FILTER_RESULT_FAIL
return nauthilus_builtin.FILTER_ACCEPT, nauthilus_builtin.FILTER_RESULT_FAIL
end
end

return nauthilus_builtin.FILTER_ACCEPT, nauthilus_builtin.FILTER_RESULT_OK
Expand Down

0 comments on commit 1b0ffd2

Please sign in to comment.