Fix text/plain mime type with healthcheck endpoint

Previously if you used an accept header of text/plain when querying the healthcheck endpoint, you would get a 406 Not Acceptable response.
This patch corrects that to allow requesting the healthcheck document in text format.

Change-Id: I0e2d06b02c06b8c77fb1c2f94207d422066a0c6d
This commit is contained in:
Michael Johnson 2023-02-17 00:21:19 +00:00
parent c2c59f4c9e
commit 8db655aed2
3 changed files with 20 additions and 1 deletions

View File

@ -39,7 +39,7 @@ class RootController(object):
# Run the oslo middleware healthcheck for /healthcheck
@pecan_expose('json')
@pecan_expose(content_type='plain/text')
@pecan_expose(content_type='text/plain')
@pecan_expose(content_type='text/html')
def healthcheck(self): # pylint: disable=inconsistent-return-statements
if CONF.api_settings.healthcheck_enabled:

View File

@ -118,6 +118,20 @@ class TestHealthCheck(base_db_test.OctaviaDBTestBase):
self.assertEqual(200, response.status_code)
self.assertEqual('OK', response.text)
def test_healthcheck_get_text_plain(self):
self.conf.config(group='healthcheck', detailed=False)
response = self._get(self._get_enabled_app(), '/healthcheck',
headers={'Accept': 'text/plain'})
self.assertEqual(200, response.status_code)
self.assertEqual('OK', response.text)
def test_healthcheck_get_text_plain_detailed(self):
self.conf.config(group='healthcheck', detailed=True)
response = self._get(self._get_enabled_app(), '/healthcheck',
headers={'Accept': 'text/plain'})
self.assertEqual(200, response.status_code)
self.assertEqual('OK', response.text)
def test_healthcheck_get_json(self):
self.conf.config(group='healthcheck', detailed=False)
response = self._get(self._get_enabled_app(), '/healthcheck',

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixed the ability to use the 'text/plain' mime type with the healthcheck
endpoint.