From 0d68f67049901332334db98c28047bcd1d6e6567 Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Mon, 26 Feb 2018 22:53:52 -0800 Subject: [PATCH] routes: make coll route config extendable to support prefix routing for localization ukwa/ukwa-pywb#11 split init_routes() into init_coll_routes() and make_coll_routes() which retrieves a list of per-collection routes only --- pywb/apps/frontendapp.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pywb/apps/frontendapp.py b/pywb/apps/frontendapp.py index 35adf401..ac942c06 100644 --- a/pywb/apps/frontendapp.py +++ b/pywb/apps/frontendapp.py @@ -91,8 +91,6 @@ class FrontEndApp(object): self.cdx_api_endpoint = config.get('cdx_api_endpoint', '/cdx') - self._init_routes() - upstream_paths = self.get_upstream_paths(self.warcserver_server.port) framed_replay = config.get('framed_replay', True) @@ -106,6 +104,8 @@ class FrontEndApp(object): metadata_templ = os.path.join(self.warcserver.root_dir, '{coll}', 'metadata.yaml') self.metadata_cache = MetadataCache(metadata_templ) + self._init_routes() + def _init_routes(self): """Initialize the routes and based on the configuration file makes available specific routes (proxy mode, record)""" @@ -500,6 +500,11 @@ class FrontEndApp(object): # store original script_name (original prefix) before modifications are made environ['pywb.app_prefix'] = environ.get('SCRIPT_NAME', '') + lang = args.pop('lang', '') + if lang: + pop_path_info(environ) + environ['pywb_lang'] = lang + response = endpoint(environ, **args) except HTTPException as hte: