From c008cbcea05e6166ba3137e97a0f3d93b709637a Mon Sep 17 00:00:00 2001 From: Morgan Fainberg Date: Fri, 13 Jul 2018 20:48:35 -0400 Subject: [PATCH] Allow class-level definition of API URL Prefix Add the ability to define API URL Prefix at the class-level. This will be used only if no ap_url_prefix is passed into __init__. Flask-restful handles prefixes in the order of `BAE` as used in Keystone: * Blueprint * API * Endpoint (flask-endpoint) This allows for additional prefixes such as "OS-TRUST" for legacy/converted extension code that has not been updated to use non-"OS" prefixed pathes. Change-Id: I7acf2f16a25efc6a801e6c87c1aac436bb8e5453 Partial-Bug: #1776504 --- keystone/server/flask/common.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/keystone/server/flask/common.py b/keystone/server/flask/common.py index 299523e725..a321cbcae1 100644 --- a/keystone/server/flask/common.py +++ b/keystone/server/flask/common.py @@ -239,7 +239,10 @@ class APIBase(object): if api_url_prefix and not api_url_prefix.startswith('/'): self._api_url_prefix = '/%s' % api_url_prefix else: - self._api_url_prefix = api_url_prefix + # NOTE(morgan): If the api_url_prefix is empty fall back on the + # class-level defined `_api_url_prefix` if it is set. + self._api_url_prefix = (api_url_prefix or + getattr(self, '_api_url_prefix', '')) if blueprint_url_prefix and not blueprint_url_prefix.startswith('/'): self._blueprint_url_prefix = self._build_bp_url_prefix(