From 326cd1d91776149f441b5f94d61976507dbc0709 Mon Sep 17 00:00:00 2001 From: Brice Schaffner Date: Thu, 1 Sep 2022 11:25:45 +0200 Subject: [PATCH] BGDIINF_SB-2544: Removed the route prefix from the liveness and readiness probes --- app/helpers/route.py | 21 --------------------- app/routes.py | 13 ++++++------- 2 files changed, 6 insertions(+), 28 deletions(-) delete mode 100644 app/helpers/route.py diff --git a/app/helpers/route.py b/app/helpers/route.py deleted file mode 100644 index 40beb74e..00000000 --- a/app/helpers/route.py +++ /dev/null @@ -1,21 +0,0 @@ -from functools import wraps - - -def prefix_route(route_decorator, prefix='', fmt='{prefix}{route}'): - """Defines a new route decorator with a prefix. - - Args: - route_decorator: route decorator to enhanced - prefix: prefix to add to the route - fmt: string format to use for adding the prefix - - Returns: - new decorator with prefixed route. - """ - - @wraps(route_decorator) - def newroute(route, *args, **kwargs): - """New function to prefix the route""" - return route_decorator(fmt.format(prefix=prefix, route=route), *args, **kwargs) - - return newroute diff --git a/app/routes.py b/app/routes.py index 64355998..f4cf0c46 100644 --- a/app/routes.py +++ b/app/routes.py @@ -19,7 +19,6 @@ from app.helpers.height_helpers import get_height from app.helpers.profile_helpers import PROFILE_DEFAULT_AMOUNT_POINTS from app.helpers.profile_helpers import get_profile -from app.helpers.route import prefix_route from app.helpers.validation import bboxes from app.helpers.validation import srs_guesser from app.helpers.validation import validate_sr @@ -28,7 +27,7 @@ from app.statistics.statistics import prepare_data from app.version import APP_VERSION -app.route = prefix_route(app.route, '/rest/services/') +ROUTE_PREFIX = '/rest/services/' logger = logging.getLogger(__name__) @@ -56,7 +55,7 @@ def readiness(): return make_response(jsonify({'success': True, 'message': 'OK'})) -@app.route('/height') +@app.route(f'{ROUTE_PREFIX}/height') def height_route(): if 'easting' in request.args: lon = request.args.get('easting') @@ -91,7 +90,7 @@ def height_route(): return response -@app.route('/profile.json', methods=['GET', 'POST']) +@app.route(f'{ROUTE_PREFIX}/profile.json', methods=['GET', 'POST']) def profile_json_route(): profile, status_code = _get_profile(True) if "callback" in request.args: @@ -102,7 +101,7 @@ def profile_json_route(): return response, status_code -@app.route('/profile.csv', methods=['GET', 'POST']) +@app.route(f'{ROUTE_PREFIX}/profile.csv', methods=['GET', 'POST']) def profile_csv_route(): if "callback" in request.args: abort(400, 'callback parameter not supported') @@ -169,11 +168,11 @@ def _get_profile(output_to_json): # if in debug, we add the route to the statistics page, otherwise it is not visible if app.debug: - @app.route('/stats') + @app.route(f'{ROUTE_PREFIX}/stats') def generate_stats(): return render_template('statistics.html') - @app.route('/stats_data') + @app.route(f'{ROUTE_PREFIX}/stats_data') def stats_data(): metadata = load_json("metadata.json") return app.response_class(prepare_data(metadata), content_type='application/json')