Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gateway/src/apicast/http_proxy.lua: remove unused code #1435

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions gateway/src/apicast/http_proxy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ local format = string.format

local resty_url = require "resty.url"
local resty_resolver = require 'resty.resolver'
local round_robin = require 'resty.balancer.round_robin'
local http_proxy = require 'resty.http.proxy'
local file_reader = require("resty.file").file_reader
local concat = table.concat

local _M = { }

function _M.reset()
_M.balancer = round_robin.new()
_M.resolver = resty_resolver
_M.http_backend = require('resty.http_ng.backend.resty')
_M.dns_resolution = 'apicast' -- can be set to 'proxy' to let proxy do the name resolution
Expand All @@ -32,45 +30,6 @@ local function resolve_servers(uri)
return resolver:get_servers(uri.host, uri)
end

function _M.resolve(uri)
local balancer = _M.balancer

if not balancer then
return nil, 'not initialized'
end

local servers, err = resolve_servers(uri)

if err then
return nil, err
end

local peers = balancer:peers(servers)
local peer = balancer:select_peer(peers)

local ip = uri.host
local port = uri.port

if peer then
ip = peer[1]
port = peer[2]
end

return ip, port
end

-- #TODO: This local function is no longer called as of PR#1323 and should be removed
local function resolve(uri)
local host = uri.host
local port = uri.port

if _M.dns_resolution == 'apicast' then
host, port = _M.resolve(uri)
end

return host, port or resty_url.default_port(uri.scheme)
end

local function absolute_url(uri)
-- target server requires hostname not IP and DNS resolution is left to the proxy itself as specified in the RFC #7231
-- https://httpwg.org/specs/rfc7231.html#CONNECT
Expand Down
Loading