Redirects for legacy URLs

This commit is contained in:
Kovid Goyal 2016-02-19 09:29:58 +05:30
parent fab5424b7a
commit 1be07c21d9
2 changed files with 20 additions and 1 deletions

View File

@ -173,7 +173,7 @@ class Handler(object):
prefer_basic_auth = {'auto':has_ssl, 'basic':True}.get(opts.auth_mode, 'digest')
self.auth_controller = AuthController(user_credentials=ctx.user_manager, prefer_basic_auth=prefer_basic_auth)
self.router = Router(ctx=ctx, url_prefix=opts.url_prefix, auth_controller=self.auth_controller)
for module in ('content', 'ajax', 'code'):
for module in ('content', 'ajax', 'code', 'legacy'):
module = import_module('calibre.srv.' + module)
self.router.load_routes(vars(module).itervalues())
self.router.finalize()

19
src/calibre/srv/legacy.py Normal file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import (unicode_literals, division, absolute_import,
print_function)
from calibre.srv.errors import HTTPRedirect
from calibre.srv.routes import endpoint
@endpoint('/browse/{+rest=""}')
def browse(ctx, rd, rest):
raise HTTPRedirect(ctx.url_for('') or '/')
@endpoint('/mobile/{+rest=""}')
def mobile(ctx, rd, rest):
raise HTTPRedirect(ctx.url_for('') or '/')