mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
proxy: add 'proxy_coll_select' config which will require a proxy-auth to select a collection for proxy mode.
Otherwise, defaults to first available collection, though proxy-auth can still be sent to specify different collection
This commit is contained in:
parent
1317b2b10f
commit
1b1a1f8115
@ -91,6 +91,10 @@ static_routes:
|
||||
# Enable simple http proxy mode
|
||||
enable_http_proxy: true
|
||||
|
||||
# additional options for routing
|
||||
routing_options:
|
||||
proxy_coll_select: false
|
||||
|
||||
# enable cdx server api for querying cdx directly (experimental)
|
||||
enable_cdx_api: true
|
||||
|
||||
|
@ -49,9 +49,15 @@ class ProxyRouter(object):
|
||||
|
||||
self.error_view = kwargs.get('error_view')
|
||||
|
||||
self.auth_msg = kwargs.get('auth_msg',
|
||||
routing_options = kwargs.get('routing_options')
|
||||
if not routing_options:
|
||||
routing_options = {}
|
||||
|
||||
self.auth_msg = routing_options.get('auth_msg',
|
||||
'Please enter name of a collection to use for proxy mode')
|
||||
|
||||
self.proxy_coll_select = routing_options.get('proxy_coll_select', False)
|
||||
|
||||
def __call__(self, env):
|
||||
url = env['REL_REQUEST_URI']
|
||||
|
||||
@ -76,7 +82,6 @@ class ProxyRouter(object):
|
||||
|
||||
for r in self.routes:
|
||||
matcher, c = r.is_handling(proxy_coll)
|
||||
print r.regex.pattern
|
||||
if matcher:
|
||||
route = r
|
||||
coll = c
|
||||
@ -85,8 +90,8 @@ class ProxyRouter(object):
|
||||
if not route:
|
||||
return self.proxy_auth_coll_response()
|
||||
|
||||
print 'COLL ', coll
|
||||
|
||||
elif self.proxy_coll_select:
|
||||
return self.proxy_auth_coll_response()
|
||||
else:
|
||||
route = self.routes[0]
|
||||
coll = self.routes[0].regex.pattern
|
||||
|
@ -237,5 +237,7 @@ def create_wb_router(passed_config={}):
|
||||
'Home Page'),
|
||||
|
||||
error_view=J2TemplateView.create_template(config.get('error_html'),
|
||||
'Error Page')
|
||||
'Error Page'),
|
||||
|
||||
routing_options=config.get('routing_options')
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user