mirror of
https://github.com/ceph/ceph
synced 2025-01-01 00:22:25 +00:00
mgr/dashboard_v2: Fix content type (body) of error page
Signed-off-by: Patrick Nawracay <pnawracay@suse.com>
This commit is contained in:
parent
c866b73377
commit
f4624947d6
@ -11,7 +11,7 @@ import cherrypy
|
||||
from mgr_module import MgrModule
|
||||
|
||||
from .controllers.auth import Auth
|
||||
from .tools import load_controllers
|
||||
from .tools import load_controllers, json_error_page
|
||||
|
||||
|
||||
# cherrypy likes to sys.exit on error. don't let it take us down too!
|
||||
@ -54,7 +54,8 @@ class Module(MgrModule):
|
||||
cherrypy.config.update({
|
||||
'server.socket_host': server_addr,
|
||||
'server.socket_port': int(server_port),
|
||||
'engine.autoreload.on': False
|
||||
'engine.autoreload.on': False,
|
||||
'error_page.default': json_error_page
|
||||
})
|
||||
cherrypy.tools.authenticate = cherrypy.Tool('before_handler',
|
||||
Auth.check_auth)
|
||||
|
@ -69,7 +69,8 @@ def load_controllers(mgrmodule):
|
||||
return controllers
|
||||
|
||||
|
||||
def _json_error_page(status, message, traceback, version):
|
||||
def json_error_page(status, message, traceback, version):
|
||||
cherrypy.response.headers['Content-Type'] = 'application/json'
|
||||
return json.dumps(dict(status=status, detail=message, traceback=traceback,
|
||||
version=version))
|
||||
|
||||
@ -104,7 +105,7 @@ class BaseController(six.with_metaclass(BaseControllerMeta, object)):
|
||||
_mgr_module = None
|
||||
|
||||
_cp_config_default = {
|
||||
'request.error_page': {'default': _json_error_page},
|
||||
'request.error_page': {'default': json_error_page},
|
||||
}
|
||||
|
||||
@property
|
||||
@ -194,7 +195,7 @@ class RESTController(BaseController):
|
||||
@cherrypy.expose
|
||||
def default(self, *vpath, **params):
|
||||
cherrypy.config.update({
|
||||
'error_page.default': _json_error_page})
|
||||
'error_page.default': json_error_page})
|
||||
obj_key, detail_route_name = self.split_vpath(vpath)
|
||||
method, status_code = self._get_method(obj_key, detail_route_name)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user