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

feature: support new field for Service object #1777

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions apisix/http/router/radixtree_host_uri.lua
Expand Up @@ -17,6 +17,9 @@
local require = require
local router = require("resty.radixtree")
local core = require("apisix.core")
local plugin = require("apisix.plugin")
local service_fetch = require("apisix.http.service").get

local ipairs = ipairs
local type = type
local error = error
Expand Down Expand Up @@ -52,6 +55,12 @@ local function push_host_router(route, host_routes, only_uri_routes)
end

local hosts = route.value.hosts or {route.value.host}
if #hosts == 0 and route.value.service_id then
local service = service_fetch(route.value.service_id)
if service.value.hosts ~= nil then
hosts = service.value.hosts
end
end

local radixtree_route = {
paths = route.value.uris or route.value.uri,
Expand Down
5 changes: 5 additions & 0 deletions apisix/schema_def.lua
Expand Up @@ -498,6 +498,11 @@ _M.service = {
type = "object",
properties = {
id = id_schema,
hosts = {
type = "array",
items = host_def,
uniqueItems = true,
},
plugins = plugins_schema,
upstream = upstream_schema,
upstream_id = id_schema,
Expand Down