Skip to content

Commit

Permalink
fix(admin) fix regression of trailing slash in targets uri
Browse files Browse the repository at this point in the history
With the trailing slash the `.../targets/active` endpoint would
return a "method not allowed" error

fixes #2840
  • Loading branch information
Tieske committed Sep 12, 2017
1 parent c7b4b48 commit 7644acd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion kong/api/routes/upstreams.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ return {
end,
},

["/upstreams/:upstream_name_or_id/targets/active/"] = {
["/upstreams/:upstream_name_or_id/targets/active"] = {
before = function(self, dao_factory, helpers)
crud.find_upstream_by_name_or_id(self, dao_factory, helpers)
self.params.upstream_id = self.upstream.id
Expand Down
6 changes: 3 additions & 3 deletions spec/02-integration/04-admin_api/08-targets_routes_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ describe("Admin API", function()
it("only shows active targets", function()
local res = assert(client:send {
method = "GET",
path = "/upstreams/" .. upstream_name3 .. "/targets/active/",
path = "/upstreams/" .. upstream_name3 .. "/targets/active",
})
assert.response(res).has.status(200)
local json = assert.response(res).has.jsonbody()
Expand Down Expand Up @@ -366,7 +366,7 @@ describe("Admin API", function()

local active = assert(client:send {
method = "GET",
path = "/upstreams/" .. upstream_name4 .. "/targets/active/",
path = "/upstreams/" .. upstream_name4 .. "/targets/active",
})
assert.response(active).has.status(200)
json = assert.response(active).has.jsonbody()
Expand All @@ -393,7 +393,7 @@ describe("Admin API", function()

local active = assert(client:send {
method = "GET",
path = "/upstreams/" .. upstream_name4 .. "/targets/active/",
path = "/upstreams/" .. upstream_name4 .. "/targets/active",
})
assert.response(active).has.status(200)
json = assert.response(active).has.jsonbody()
Expand Down

0 comments on commit 7644acd

Please sign in to comment.