Skip to content

Commit

Permalink
feat(api): support official media-type of yaml in /config endpoint (#…
Browse files Browse the repository at this point in the history
…13713)

The https://datatracker.ietf.org/doc/html/rfc9512 specifies the official media-type
to YAML as `application/yaml`. We had support for `text/yaml` (which is kept for
backward compatibility), but this commit adds support for `application/yaml` as well.

Signed-off-by: Aapo Talvensaari <aapo.talvensaari@gmail.com>
  • Loading branch information
bungle committed Sep 26, 2024
1 parent 204ba17 commit a6ccbb1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelog/unreleased/kong/feat-api-yaml-media-type.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
message: |
**Admin API**: Added support for official YAML media-type (application/yaml) to /config endpoint.
type: feature
scope: Admin API
4 changes: 3 additions & 1 deletion kong/api/api_helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ function _M.before_filter(self)
elseif sub(content_type, 1, 16) == "application/json"
or sub(content_type, 1, 19) == "multipart/form-data"
or sub(content_type, 1, 33) == "application/x-www-form-urlencoded"
or (ACCEPTS_YAML[self.route_name] and sub(content_type, 1, 9) == "text/yaml")
or (ACCEPTS_YAML[self.route_name] and
(sub(content_type, 1, 16) == "application/yaml" or
sub(content_type, 1, 9) == "text/yaml"))
then
return
end
Expand Down
6 changes: 3 additions & 3 deletions spec/02-integration/04-admin_api/15-off_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ describe("Admin API #off", function()
- username: "bobby_in_yaml_body"
]]),
headers = {
["Content-Type"] = "text/yaml"
["Content-Type"] = "application/yaml"
},
})

Expand Down Expand Up @@ -3290,7 +3290,7 @@ describe("Admin API #off worker_consistency=eventual", function()
- name: prometheus
]]),
headers = {
["Content-Type"] = "text/yaml"
["Content-Type"] = "application/yaml"
},
})
assert.response(res).has.status(201)
Expand Down Expand Up @@ -3320,7 +3320,7 @@ describe("Admin API #off worker_consistency=eventual", function()
- name: prometheus
]]),
headers = {
["Content-Type"] = "text/yaml"
["Content-Type"] = "application/yaml"
},
})
assert.response(res).has.status(201)
Expand Down

1 comment on commit a6ccbb1

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:a6ccbb1af2169a9edbf4491a91ecaf5d2d7fb067
Artifacts available https://github.com/Kong/kong/actions/runs/11056397391

Please sign in to comment.