Skip to content
Snippets Groups Projects
Commit a372a96d authored by Nikolay Stanchev's avatar Nikolay Stanchev
Browse files

Updates CLMC to always set the HTTP Accept header to application/json -...

Updates CLMC to always set the HTTP Accept header to application/json - otherwise, error messages might be sent as HTML
parent 2bbc6323
No related branches found
No related tags found
No related merge requests found
...@@ -60,6 +60,8 @@ def main(global_config, **settings): ...@@ -60,6 +60,8 @@ def main(global_config, **settings):
config = Configurator(settings=settings) config = Configurator(settings=settings)
config.add_tween('clmcservice.tweens.accept_header_tween_factory')
# add routes of the WHOAMI API # add routes of the WHOAMI API
config.add_route('whoami_endpoints', '/whoami/endpoints') config.add_route('whoami_endpoints', '/whoami/endpoints')
config.add_route('whoami_endpoints_instance', 'whoami/endpoints/instance') config.add_route('whoami_endpoints_instance', 'whoami/endpoints/instance')
......
#!/usr/bin/python3
"""
// © University of Southampton IT Innovation Centre, 2018
//
// Copyright in this software belongs to University of Southampton
// IT Innovation Centre of Gamma House, Enterprise Road,
// Chilworth Science Park, Southampton, SO16 7NS, UK.
//
// This software may not be used, sold, licensed, transferred, copied
// or reproduced in whole or in part in any manner or form or in or
// on any media by any person other than in accordance with the terms
// of the Licence Agreement supplied with the software, or otherwise
// without the prior written consent of the copyright owners.
//
// This software is distributed WITHOUT ANY WARRANTY, without even the
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE, except where stated in the Licence Agreement supplied with
// the software.
//
// Created By : Nikolay Stanchev
// Created Date : 02-11-2018
// Created for Project : FLAME
"""
def accept_header_tween_factory(handler, registry):
"""
Since clmc-service is currently based on JSON only, make sure an application/json header is passed with the request
"""
def accept_header_tween(request):
request.accept = 'application/json'
response = handler(request)
return response
return accept_header_tween
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment