Merge pull request #1854 from summerswallow-whi/extra_handler

Add custom handlers and allow setting of defaults
This commit is contained in:
Min RK
2018-05-15 08:55:15 +01:00
committed by GitHub
2 changed files with 8 additions and 0 deletions

View File

@@ -937,6 +937,9 @@ class JupyterHub(Application):
handlers[i] = tuple(lis)
return handlers
extra_handlers = List(help="Register extra page handlers for jupyterhub, should be of the form (<regex>,handler)").tag(config=True)
default_url = Any(default_value=None, help='specify default URL for "next_url" (e.g. when user directs to "/"').tag(config=True)
def init_handlers(self):
h = []
# load handlers from the authenticator
@@ -945,6 +948,9 @@ class JupyterHub(Application):
h.extend(handlers.default_handlers)
h.extend(apihandlers.default_handlers)
# add any user configurable handlers.
h.extend(self.extra_handlers)
h.append((r'/logo', LogoHandler, {'path': self.logo_file}))
self.handlers = self.add_url_prefix(self.hub_prefix, h)
# some extra handlers, outside hub_prefix

View File

@@ -428,6 +428,8 @@ class BaseHandler(RequestHandler):
self.log.warning("Redirecting %s to %s. For sharing public links, use /user-redirect/",
self.request.uri, next_url,
)
if not next_url and self.config.JupyterHub.get('default_url'):
next_url = self.config.JupyterHub['default_url']
if not next_url:
# default URL after login