Skip to content

Commit

Permalink
rename http_codes to http_statuses
Browse files Browse the repository at this point in the history
Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
  • Loading branch information
eloycoto committed Nov 30, 2020
1 parent 1021e53 commit fb1e622
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}
},
"properties": {
"http_codes": {
"http_statuses": {
"title": "HTTP status codes map",
"$ref": "#/definitions/codes" }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ local new = _M.new

function _M.new(config)
local self = new(config)
self.http_codes = {}
for _, code in ipairs(config.http_codes or {}) do
self.http_codes[code.upstream] = code.apicast
self.http_statuses = {}
for _, code in ipairs(config.http_statuses or {}) do
self.http_statuses[code.upstream] = code.apicast
end
return self
end

function _M:header_filter()
ngx.status = self.http_codes[ngx.status] or ngx.status
ngx.status = self.http_statuses[ngx.status] or ngx.status
end

return _M
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('Status Codes overwrite policy', function()

it('mapped correctly valid status code', function()
local policy = StatusCodeOverwrite.new({
http_codes = {
http_statuses = {
{ upstream=200, apicast=201 }
}
})
Expand All @@ -22,7 +22,7 @@ describe('Status Codes overwrite policy', function()
it('invalid code fails correctly', function()
assert.has_error(function()
return StatusCodeOverwrite.new({
http_codes = {
http_statuses = {
{ upstream=1, apicast=201 }
}})
end)
Expand All @@ -33,7 +33,7 @@ describe('Status Codes overwrite policy', function()
it('Upstream code is not defined', function()
assert.has_error(function()
return StatusCodeOverwrite.new({
http_codes = {
http_statuses = {
{ apicast=201 }
}})
end)
Expand All @@ -42,7 +42,7 @@ describe('Status Codes overwrite policy', function()
it('Apicast code is not defined', function()
assert.has_error(function()
return StatusCodeOverwrite.new({
http_codes = {
http_statuses = {
{ upstream=201 }
}})
end)
Expand Down
4 changes: 2 additions & 2 deletions t/apicast-policy-statuscode_overwrite.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ __DATA__
"name": "statuscode_overwrite",
"version": "builtin",
"configuration": {
"http_codes": [
"http_statuses": [
{
"upstream": 200,
"apicast": 201
Expand Down Expand Up @@ -91,7 +91,7 @@ __DATA__
"name": "statuscode_overwrite",
"version": "builtin",
"configuration": {
"http_codes": [
"http_statuses": [
{
"upstream": 200,
"apicast": 201
Expand Down

0 comments on commit fb1e622

Please sign in to comment.