function _M.setRouteWithOverride()

in scripts/lua/policies/backendRouting.lua [42:69]


function _M.setRouteWithOverride(backendUrl, gatewayPath, override)
  local u = url.parse(backendUrl)
  if u.scheme == nil then
    u = url.parse(utils.concatStrings({'http://', backendUrl}))
  end
  
  if u.path:sub(-15) == '$(request.path)' then
    u.path = utils.concatStrings({u.path:sub(1, -16), u.path:sub(-16, -16) == '/' and '' or '/', gatewayPath})
    ngx.req.set_uri(u.path)
  else
    ngx.req.set_uri(_M.getUriPath(u.path))
  end
  ngx.var.backendUrl = backendUrl

  
  if override ~= nil then
    local bou = url.parse(override)
    u.scheme = bou.scheme
    u:setAuthority(bou.authority)

    
    local bu = url.parse(backendUrl)
    bu.scheme = bou.scheme
    bu:setAuthority(bou.authority)
    ngx.var.backendUrl = bu:build()
  end
  setUpstream(u)
end